-
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
Changes from all commits
4824f0a
2efa7b1
f09627e
103f479
fa018a4
3ace134
7185f6b
42502e9
a5ca969
00de41f
6596c2a
efd76c8
9e3bce6
7d72544
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import numpy as np | ||
import cv2 as cv | ||
import sys | ||
|
||
from argparse import ArgumentParser | ||
|
||
def get_depth_list(folder): | ||
f = open(folder + '/depth.txt', 'r') | ||
rgb = [folder + '/' + s for s in f.read().split() if s.endswith('.png')] | ||
return rgb | ||
|
||
def kinfu_demo(): | ||
parser = ArgumentParser() | ||
parser.add_argument( | ||
"-i", "--input", help="Required. Path to folder with a input image file", required=True, type=str) | ||
parser.add_argument( | ||
"-t", "--large_kinfu", help="Required. Name of KinFu type", required=False, type=str) | ||
parser.add_argument( | ||
"-ocl", "--use_opencl", help="Required. Flag of OpenCL use", required=False, type=int, default=1) | ||
|
||
args = parser.parse_args() | ||
print("Args: ", args) | ||
|
||
cv.ocl.setUseOpenCL(args.use_opencl) | ||
|
||
if (args.large_kinfu == None or args.large_kinfu == "0"): | ||
params = cv.kinfu_Params.defaultParams() | ||
kf = cv.kinfu_KinFu.create(params) | ||
elif (args.large_kinfu == "1"): | ||
params = cv.kinfu_Params.hashTSDFParams(False) | ||
kf = cv.kinfu_KinFu.create(params) | ||
else: | ||
raise ValueError("Incorrect kinfu type name") | ||
|
||
depth_list = get_depth_list(args.input) | ||
for path in depth_list: | ||
|
||
image = cv.imread(path, cv.IMREAD_ANYDEPTH) | ||
(height, width) = image.shape | ||
|
||
cv.imshow('input', image) | ||
|
||
size = height, width, 4 | ||
cvt8 = np.zeros(size, dtype=np.uint8) | ||
|
||
if not kf.update(image): | ||
kf.reset() | ||
else: | ||
kf.render(cvt8) | ||
cv.imshow('render', cvt8) | ||
cv.pollKey() | ||
cv.waitKey(0) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you mean replacing There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 We need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
if __name__ == '__main__': | ||
print(__doc__) | ||
kinfu_demo() | ||
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.
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