Skip to content

tutorial_py_fourier_transform wrong division operator fix#24440

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
COOLIRON2311:4.x
Oct 24, 2023
Merged

tutorial_py_fourier_transform wrong division operator fix#24440
asmorkalov merged 1 commit intoopencv:4.xfrom
COOLIRON2311:4.x

Conversation

@COOLIRON2311
Copy link
Copy Markdown
Contributor

@COOLIRON2311 COOLIRON2311 commented Oct 23, 2023

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Truediv (floating point division) operators on line 149 of the tutorial produce floating point result:

crow,ccol = rows/2 , cols/2

Hence, indexing operation on line 153:

mask[crow-30:crow+30, ccol-30:ccol+30] = 1

Fails with an error:

TypeError: slice indices must be integers or None or have an __index__ method

This PR fixes the error by replacing the operators with floordiv (integer division) ones.

@opencv-alalek
Copy link
Copy Markdown
Contributor

BTW, It makes sense to revise one more time all Python code for making Python3 friendly.

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov asmorkalov merged commit 8b47361 into opencv:4.x Oct 24, 2023
@asmorkalov asmorkalov self-assigned this Oct 24, 2023
@asmorkalov asmorkalov mentioned this pull request Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants