8000 tutorial_py_fourier_transform wrong division operator fix by COOLIRON2311 · Pull Request #24440 · opencv/opencv · GitHub
[go: up one dir, main page]

Skip to content

tutorial_py_fourier_transform wrong division operator fix #24440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

COOLIRON2311
Copy link
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
Contributor

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

Copy link
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
0