-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fakenect: support applications needing _DEPTH_MM and _VIDEO_YUV_RAW #531
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
Conversation
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 is a very nicely formatted PR! I look forward to reviewing it more closely.
JSON_Object *dev_js = json_object(js); | ||
|
||
JSON_Value *reg_info_val = json_value_init_object(); | ||
JSON_Object *reg_info = json_object(reg_info_val); |
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.
Does this one need to be freed as well?
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'm fairly sure parson will recursively free the objects given the top-level one to free at the end, but can double check that
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.
ok, just to confirm; json_value_free()
is recursive, so since that object got linked into the hierarchy of the top-level js
value then it will also be freed.
char fn[512]; | ||
snprintf(fn, sizeof(fn), "%s/device.json", input_path); | ||
|
||
JSON_Value *js = json_parse_file(fn); |
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.
Should it skip all the rest if device.json
doesn't exist? Ideally old recordings will still work.
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.
Yeah makes sense. In that case it probably also makes sense to move the follow-up call to freenect_init_registration
to the bottom of read_device_info
at a point where we know we have read the required reg_info
state.
I've tested an updated version with this change and will update my pull request.
Since I decided to return silently if we fail to load a device.json (for compatibility) I also added a check in freenect_set_depth_mode
whereby requesting _DEPTH_MM
will result in a "Warning:..." if registration state wasn't previously loaded.
For applications that depend on getting and setting the IR brightness this adds freenect_get/set_ir_brightness wrapper apis. Signed-off-by: Robert Bragg <[email protected]>
a99a814
to
ca98225
Compare
Just a couple more comments. I'd like the endless loop to be a separate PR (maybe with a runtime switch), just in case anyone depends on the current behavior. Also I think parson should be a submodule instead of being embedded in this repo to make it easier to stay current with upstream. I just did
and then updated CMakeLists.txt to |
I can only ask you to possibly reconsider using a submodule to make it easier to update a single .c file :) If you've used git submodules before and know how it goes that's fine and I won't loose sleep over it, but git submodules adds quite a faff to the experience imho. In particular it will affect the basic instructions for any user/developer cloning and building libfreenect. If the file is copied then updating goes something like:
(and you / maintainers are the only ones who have to do these steps) With submodules, now everyone needs to learn to pass To update parson it goes something like:
(seems like a very similar effort, just one step fewer than above, to update from a maintainer pov, but at the cost of complicating basic operations like cloning the repo) As you might be able to tell, it's just one of those features that makes me sigh very heavily whenever I see it used :) (I even went overboard once and attempted writing a replacement: https://github.com/rib/git-subdir) Anyway, I've pushed a https://github.com/rib/libfreenect/tree/fakenect-depth-mm-video-yuv-submodule branch that squashes in the addition of a submodule as you suggest, but will just wait for a confirmation to update the pull request with that branch. |
ca98225
to
cc563b5
Compare
Ok, you convinced me. There's one bugfix upstream that needs to be included, but other than that it's good without the submodule.
|
This adds a minimal JSON parser api called Parson which we intend to use for recording and loading Kinect registration parameters so that fakenect will be able to support mapping DEPTH_11BIT data to DEPTH_MM. The upstream for Parson is: https://github.com/kgabis/parson Signed-off-by: Robert Bragg <[email protected]>
This adds an alternative utility api for mapping depth values that have already been unpacked into 16 bit values (i.e. the FREENECT_DEPTH_11BIT format) into MM (i.e. the FREENECT_DEPTH_MM format). The plan is to use this in fakenect for mapping recorded _DEPTH_11BIT data into _DEPTH_MM if that's what the application requires. Signed-off-by: Robert Bragg <[email protected]>
So that it will be possible to use fakenect recorded data with applications expecting _DEPTH_MM data the record tool now writes the registration parameters to a device.json file. Signed-off-by: Robert Bragg <[email protected]>
This adds support for converting the recorded _VIDEO_RGB data to _VIDEO_YUV_RAW and mapping _DEPTH_11BIT to _DEPTH_MM for applications requiring these formats. Signed-off-by: Robert Bragg <[email protected]>
cc563b5
to
7c2e28d
Compare
We have a test application that's configuring a Kinect to capture _DEPTH_MM and _VIDEO_YUV_RAW video data. So that we can work with pre-recorded data this updates fakenect so that it can convert recorded _DEPTH_11BIT data to _MM and convert _RGB data into _YUV_RAW.
One notable issue with being able to map _DEPTH_11BIT data to _DEPTH_MM was that we need to save and load the registration parameters, which this does by introducing a device.json file in the output directory.
Another somewhat orthogonal change in this branch is make fakenect loop over the recorded data instead of stopping at the end since that was more practical behaviour for our use case, and it seems like a reasonable default behaviour considering that the Kinect camera doesn't normally stop spontaneously while in use. I could pull this patch out to a separate pull request if preferred.
Yet another orthgonal change was to add support for the freenect_get/set_ir_brightness apis that our application also uses but they weren't interposed by fakenect (again don't mind factoring this out to a separate pull request if preferred).