Skip to content

fix cvtColor-error#21224

Merged
alalek merged 8 commits intoopencv:3.4from
UncleLLD:fix-cvtColor-error
Dec 9, 2021
Merged

fix cvtColor-error#21224
alalek merged 8 commits intoopencv:3.4from
UncleLLD:fix-cvtColor-error

Conversation

@UncleLLD
Copy link
Copy Markdown
Contributor

@UncleLLD UncleLLD commented Dec 9, 2021

fix the iusse: #21223

  • Added a conditional sentence to judge whether ret is true
  • Modify the problem of using the next keyword as a variable
  • some python code style: add space

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you for contribution!

Comment on lines +37 to +38
if ret:
frame_gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please reuse code pattern from already existed in other samples (e.g. here)

ret, frame = cap.read()
if not ret:
    ... message...
    waitKey(0)
    break

... processing code kept here ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

got it, i have changed it according to the above code example, please check it, thanks

if k == 27:
if ret:
frame2_gray = cv.cvtColor(frame2, cv.COLOR_BGR2GRAY)
flow = cv.calcOpticalFlowFarneback(frame1_gray, frame2_gray, None, 0.5, 3, 15, 3, 5, 1.2, 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

prvs,next
frame1_gray, frame2_gray

Please don't rename vars (this introduces unnecessary changes in the patch)

Copy link
Copy Markdown
Contributor Author

@UncleLLD UncleLLD Dec 9, 2021

Choose a reason for hiding this comment

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

got it, i have changed it well, please check it, thanks

@UncleLLD
Copy link
Copy Markdown
Contributor Author

UncleLLD commented Dec 9, 2021

i have changed the above code according to your advices, thanks

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thank you 👍

@alalek alalek merged commit 62a010a into opencv:3.4 Dec 9, 2021
@UncleLLD UncleLLD deleted the fix-cvtColor-error branch December 10, 2021 13:02
@alalek alalek mentioned this pull request Dec 11, 2021
@alalek alalek mentioned this pull request Dec 30, 2021
@alalek alalek mentioned this pull request Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optical flow python example will cause an error src.empty() in function 'cvtColor' when the video ends

2 participants