Skip to content

KinFu python samples #2981

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 14 commits into from
Sep 4, 2021
Merged

KinFu python samples #2981

merged 14 commits into from
Sep 4, 2021

Conversation

DumDereDum
Copy link
Member

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

@savuor savuor self-assigned this Sep 3, 2021
Comment on lines 7 to 13
if sys.platform.find('linux')+1:
f = open(folder + '/depth.txt', 'r')
rgb = [folder + '/' + s.replace('/', '/') for s in f.read().split() if '.png' in s]
else:
f = open(folder + '\\depth.txt', 'r')
rgb = [folder + '\\' + s.replace('/', '\\') for s in f.read().split() if '.png' in s]
return rgb
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this branching?

Windows should work properly with forward slashes (/) too.


if '.png' in s

if s.endswith('.png')

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,60 @@
import cv2
import numpy as np
Copy link
Member

Choose a reason for hiding this comment

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

numpy import should go before cv2

Copy link
Member Author

Choose a reason for hiding this comment

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

done

(height, width) = image.shape

cv2.imshow('input', image)
cv2.waitKey(1)
Copy link
Member

Choose a reason for hiding this comment

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

waitKey(1)

There is pollKey() without any timeouts.

Copy link
Member Author

Choose a reason for hiding this comment

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

I cann't find this function in cv2

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done, thx


if __name__ == '__main__':
print(__doc__)
cv2.setUseOptimized(True)
Copy link
Member

Choose a reason for hiding this comment

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

cv2.setUseOptimized(True)

Useless call. Optimized code path is run by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

It added for the case when you need to off ocl

Copy link
Member

Choose a reason for hiding this comment

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

=> ArgumentParser is for that case.

Anyway it turns off too many parts.
For OpenCL there is cv.ocl.setUseOpenCL() call

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,60 @@
import cv2
Copy link
Member

Choose a reason for hiding this comment

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

import cv2 as cv

Replace cv2. => cv.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@savuor savuor self-requested a review September 3, 2021 13:58
else:
kf.render(cvt8)
cv.imshow('render', cvt8)

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should have waitKey(0) after the loop before exit.
Otherwise app will just close in the end. User can't see the final 'render' frame.

Copy link
Member Author

@DumDereDum DumDereDum Sep 3, 2021

Choose a reason for hiding this comment

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

do you mean replacing pollKey() after the loop ?

Copy link
Member

Choose a reason for hiding this comment

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

pollKey() must be called after each imshow() call to update GUI window content (handle UI redraw events). See imshow() documentation.

We need waitKey(0) for infinite wait after loop and before calling cv.destroyAllWindows().

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@alalek
Copy link
Member

alalek commented Sep 3, 2021

Why do we have 2 cv.waitKey(0) calls?

@DumDereDum
Copy link
Member Author

@alalek , which one i need to leave?

@alalek
Copy link
Member

alalek commented Sep 3, 2021

The first one should be enough.

@DumDereDum
Copy link
Member Author

@alalek done)

Copy link
Contributor

@savuor savuor left a comment

Choose a reason for hiding this comment

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

2 pollKey changes and it's fine

(height, width) = image.shape

cv.imshow('input', image)
cv.pollKey()
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need that pollKey() call

Copy link
Member Author

Choose a reason for hiding this comment

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

done

else:
kf.render(cvt8)
cv.imshow('render', cvt8)
cv.pollKey()
Copy link
Contributor

Choose a reason for hiding this comment

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

This pollKey() call should be done after the if block

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@alalek alalek merged commit 78acb19 into opencv:master Sep 4, 2021
@alalek alalek mentioned this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants