Skip to content

Commit

Permalink
1. Updated record to output the mode struct used. This is informative…
Browse files Browse the repository at this point in the history
…, will be changed in the future to save as metadata, and is helpful for setting the default struct in Fakenect.

2. Added fakenect functions that correspond to the new ones in the API.  Note that fakenect only works for the previous default resolution/mode at the moment.

Future Change (as a heads up to other devs)
A later update will store the modes in metadata with the dump and just ensure that if you are setting things that they belong to the recorded mode.  The current behavior will be the default for people with datasets made before this.
Signed-off-by: Brandyn A. White <bwhite@dappervision.com>
  • Loading branch information
Brandyn A. White authored and qdot committed Mar 26, 2011
1 parent 2893622 commit 435ec19
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
32 changes: 32 additions & 0 deletions fakenect/fakenect.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,38 @@ void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb)
cur_rgb_cb = cb;
}

int freenect_set_video_mode(freenect_device* dev, const freenect_frame_mode mode)
{
// Always say it was successful but continue to pass through the
// underlying data. Would be better to check for conflict.
return 0;
}

int freenect_set_depth_mode(freenect_device* dev, const freenect_frame_mode mode)
{
// Always say it was successful but continue to pass through the
// underlying data. Would be better to check for conflict.
return 0;
}

const freenect_frame_mode freenect_find_video_mode(freenect_resolution res, freenect_video_format fmt) {
assert(FREENECT_RESOLUTION_MEDIUM == res);
assert(FREENECT_VIDEO_RGB == fmt);
// NOTE: This will leave uninitialized values if new fields are added.
// To update this line run the "record" program, look at the top output
freenect_frame_mode out = {256, 1, 921600, 640, 480, 24, 0, 30};
return out;
}

const freenect_frame_mode freenect_find_depth_mode(freenect_resolution res, freenect_depth_format fmt) {
assert(FREENECT_RESOLUTION_MEDIUM == res);
assert(FREENECT_DEPTH_11BIT == fmt);
// NOTE: This will leave uninitialized values if new fields are added.
// To update this line run the "record" program, look at the top output
freenect_frame_mode out = {256, 1, 614400, 640, 480, 11, 5, 30};
return out;
}

int freenect_num_devices(freenect_context *ctx)
{
// Always 1 device
Expand Down
13 changes: 13 additions & 0 deletions fakenect/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ void init_ffmpeg_streams()
rgb_stream = open_ffmpeg(rgb_name);
}

void print_mode(const char *name, freenect_frame_mode mode) {
/* This is just a courtesy function to let the user know the mode
if it becomes a bother for maintainability just comment out the
code in its body. It will only break if struct entries go missing.
*/
printf("%s Mode: {%d, %d, %d, %d, %d, %d, %d, %d}\n", name,
mode.reserved, mode.is_valid, mode.bytes, mode.width,
mode.height, mode.data_bits_per_pixel, mode.padding_bits_per_pixel,
mode.framerate);
}

void init()
{
freenect_context *ctx;
Expand All @@ -209,6 +220,8 @@ void init()
printf("Error: Cannot get device\n");
return;
}
print_mode("Depth", freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT));
print_mode("Video", freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB));
freenect_set_depth_mode(dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT));
freenect_start_depth(dev);
freenect_set_video_mode(dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB));
Expand Down

0 comments on commit 435ec19

Please sign in to comment.