-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
KinFu python samples #2981
Conversation
modules/rgbd/samples/kinfu_demo.py
Outdated
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 |
There was a problem hiding this comment.
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')
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
modules/rgbd/samples/kinfu_demo.py
Outdated
(height, width) = image.shape | ||
|
||
cv2.imshow('input', image) | ||
cv2.waitKey(1) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
modules/rgbd/samples/kinfu_demo.py
Outdated
|
||
if __name__ == '__main__': | ||
print(__doc__) | ||
cv2.setUseOptimized(True) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
modules/rgbd/samples/kinfu_demo.py
Outdated
@@ -0,0 +1,60 @@ | |||
import cv2 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Why do we have 2 |
@alalek , which one i need to leave? |
The first one should be enough. |
@alalek done) |
There was a problem hiding this 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
modules/rgbd/samples/kinfu_demo.py
Outdated
(height, width) = image.shape | ||
|
||
cv.imshow('input', image) | ||
cv.pollKey() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
modules/rgbd/samples/kinfu_demo.py
Outdated
else: | ||
kf.render(cvt8) | ||
cv.imshow('render', cvt8) | ||
cv.pollKey() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.