Skip to content

Commit

Permalink
camera-flags: added depth and video mirror
Browse files Browse the repository at this point in the history
Signed-off-by: Benn Snyder <benn.snyder@gmail.com>
  • Loading branch information
piedar committed Jun 30, 2013
1 parent 1ddb0fa commit 37758b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 8 additions & 1 deletion examples/glview.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ void keyPressed(unsigned char key, int x, int y)
freenect_set_flag(f_dev, FREENECT_RAW_COLOR, raw_color);
raw_color = !raw_color;
}
if (key == 'm') {
static freenect_flag_value mirror = FREENECT_ON;
freenect_set_flag(f_dev, FREENECT_MIRROR_DEPTH, mirror);
freenect_set_flag(f_dev, FREENECT_MIRROR_VIDEO, mirror);
mirror = !mirror;
}
if (key == '1') {
freenect_set_led(f_dev,LED_GREEN);
}
Expand Down Expand Up @@ -363,7 +369,8 @@ void *freenect_threadfunc(void *arg)
freenect_start_depth(f_dev);
freenect_start_video(f_dev);

printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format, 'e' - auto exposure, 'b' - white balance, r - raw color\n");
printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format\n");
printf("'e' - auto exposure, 'b' - white balance, 'r' - raw color, 'm' - mirror\n");

while (!die && freenect_process_events(f_ctx) >= 0) {
//Throttle the text output
Expand Down
12 changes: 8 additions & 4 deletions include/libfreenect.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,19 @@ typedef enum {

/// Enumeration of flags to toggle features with freenect_set_flag()
typedef enum {
FREENECT_AUTO_EXPOSURE = 1 << 14,
// values written to the CMOS register
FREENECT_AUTO_EXPOSURE = 1 << 14,
FREENECT_AUTO_WHITE_BALANCE = 1 << 1,
FREENECT_RAW_COLOR = 1 << 4,
FREENECT_RAW_COLOR = 1 << 4,
// registers to be written with 0 or 1
FREENECT_MIRROR_DEPTH = 0x0017,
FREENECT_MIRROR_VIDEO = 0x0047,
} freenect_flag;

/// Possible values for setting each `freenect_flag`
typedef enum {
FREENECT_ON = 1,
FREENECT_OFF = 0,
FREENECT_ON = 1,
} freenect_flag_value;

/// Structure to give information about the width, height, bitrate,
Expand Down Expand Up @@ -631,7 +635,7 @@ FREENECTAPI int freenect_set_depth_mode(freenect_device* dev, const freenect_fra
* Enables or disables the specified flag.
*
* @param flag Feature to set
* @param value `FREENECT_ON` or `FREENECT_OFF`
* @param value `FREENECT_OFF` or `FREENECT_ON`
*
* @return 0 on success, < 0 if error
*/
Expand Down
3 changes: 3 additions & 0 deletions src/flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@

int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value)
{
if (flag == FREENECT_MIRROR_DEPTH || flag == FREENECT_MIRROR_VIDEO)
return write_register(dev, flag, value);

uint16_t reg = read_cmos_register(dev, 0x0106);
if (reg < 0)
return reg;
Expand Down

0 comments on commit 37758b2

Please sign in to comment.