Classes | Macros | Functions | Variables
cameras.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "freenect_internal.h"
#include "registration.h"
#include "cameras.h"
#include "flags.h"
Include dependency graph for cameras.c:

Go to the source code of this file.

Classes

struct  pkt_hdr
 

Macros

#define CLAMP(x)   if (x < 0) {x = 0;} if (x > 255) {x = 255;}
 
#define depth_mode_count   6
 
#define MAKE_RESERVED(res, fmt)   (uint32_t)(((res & 0xff) << 8) | (((fmt & 0xff))))
 
#define RESERVED_TO_FORMAT(reserved)   ((reserved) & 0xff)
 
#define RESERVED_TO_RESOLUTION(reserved)   (freenect_resolution)((reserved >> 8) & 0xff)
 
#define video_mode_count   12
 

Functions

static void convert_bayer_to_rgb (uint8_t *raw_buf, uint8_t *proc_buf, freenect_frame_mode frame_mode)
 
static void convert_packed11_to_16bit (uint8_t *raw, uint16_t *frame, int n)
 
static void convert_packed_to_16bit (uint8_t *src, uint16_t *dest, int vw, int n)
 
static void convert_packed_to_8bit (uint8_t *src, uint8_t *dest, int vw, int n)
 
static void convert_uyvy_to_rgb (uint8_t *raw_buf, uint8_t *proc_buf, freenect_frame_mode frame_mode)
 
static void depth_process (freenect_device *dev, uint8_t *pkt, int len)
 
FN_INTERNAL int freenect_camera_init (freenect_device *dev)
 
FN_INTERNAL int freenect_camera_teardown (freenect_device *dev)
 
static int freenect_fetch_reg_const_shift (freenect_device *dev)
 
static int freenect_fetch_reg_info (freenect_device *dev)
 
static int freenect_fetch_reg_pad_info (freenect_device *dev)
 
static int freenect_fetch_zero_plane_info (freenect_device *dev)
 
freenect_frame_mode freenect_find_depth_mode (freenect_resolution res, freenect_depth_format fmt)
 
freenect_frame_mode freenect_find_video_mode (freenect_resolution res, freenect_video_format fmt)
 
freenect_frame_mode freenect_get_current_depth_mode (freenect_device *dev)
 
freenect_frame_mode freenect_get_current_video_mode (freenect_device *dev)
 
freenect_frame_mode freenect_get_depth_mode (int mode_num)
 
int freenect_get_depth_mode_count ()
 
freenect_frame_mode freenect_get_video_mode (int mode_num)
 
int freenect_get_video_mode_count ()
 
int freenect_set_depth_buffer (freenect_device *dev, void *buf)
 
void freenect_set_depth_callback (freenect_device *dev, freenect_depth_cb cb)
 
void freenect_set_depth_chunk_callback (freenect_device *dev, freenect_chunk_cb cb)
 
int freenect_set_depth_mode (freenect_device *dev, const freenect_frame_mode mode)
 
int freenect_set_video_buffer (freenect_device *dev, void *buf)
 
void freenect_set_video_callback (freenect_device *dev, freenect_video_cb cb)
 
void freenect_set_video_chunk_callback (freenect_device *dev, freenect_chunk_cb cb)
 
int freenect_set_video_mode (freenect_device *dev, const freenect_frame_mode mode)
 
int freenect_start_depth (freenect_device *dev)
 
int freenect_start_video (freenect_device *dev)
 
int freenect_stop_depth (freenect_device *dev)
 
int freenect_stop_video (freenect_device *dev)
 
static void stream_freebufs (freenect_context *ctx, packet_stream *strm)
 
static void stream_init (freenect_context *ctx, packet_stream *strm, int rlen, int plen)
 
static int stream_process (freenect_context *ctx, packet_stream *strm, uint8_t *pkt, int len, freenect_chunk_cb cb, void *user_data)
 
static int stream_setbuf (freenect_context *ctx, packet_stream *strm, void *pbuf)
 
static void video_process (freenect_device *dev, uint8_t *pkt, int len)
 

Variables

static const freenect_frame_mode invalid_mode = {0, (freenect_resolution)0, {(freenect_video_format)0}, 0, 0, 0, 0, 0, 0, 0}
 
static freenect_frame_mode supported_depth_modes [depth_mode_count]
 
static freenect_frame_mode supported_video_modes [video_mode_count]
 

Macro Definition Documentation

#define CLAMP (   x)    if (x < 0) {x = 0;} if (x > 255) {x = 255;}

Definition at line 419 of file cameras.c.

#define depth_mode_count   6

Definition at line 64 of file cameras.c.

#define MAKE_RESERVED (   res,
  fmt 
)    (uint32_t)(((res & 0xff) << 8) | (((fmt & 0xff))))

Definition at line 37 of file cameras.c.

#define RESERVED_TO_FORMAT (   reserved)    ((reserved) & 0xff)

Definition at line 39 of file cameras.c.

#define RESERVED_TO_RESOLUTION (   reserved)    (freenect_resolution)((reserved >> 8) & 0xff)

Definition at line 38 of file cameras.c.

#define video_mode_count   12

Definition at line 41 of file cameras.c.

Function Documentation

static void convert_bayer_to_rgb ( uint8_t raw_buf,
uint8_t proc_buf,
freenect_frame_mode  frame_mode 
)
static

Definition at line 453 of file cameras.c.

static void convert_packed11_to_16bit ( uint8_t raw,
uint16_t frame,
int  n 
)
static

Definition at line 345 of file cameras.c.

static void convert_packed_to_16bit ( uint8_t src,
uint16_t dest,
int  vw,
int  n 
)
inlinestatic

Convert a packed array of n elements with vw useful bits into array of zero-padded 16bit elements.

Parameters
srcThe source packed array, of size (n * vw / 8) bytes
destThe destination unpacked array, of size (n * 2) bytes
vwThe virtual width of elements, that is the number of useful bits for each of them
nThe number of elements (in particular, of the destination array), NOT a length in bytes

Definition at line 304 of file cameras.c.

static void convert_packed_to_8bit ( uint8_t src,
uint8_t dest,
int  vw,
int  n 
)
inlinestatic

Convert a packed array of n elements with vw useful bits into array of 8bit elements, dropping LSB.

Parameters
srcThe source packed array, of size (n * vw / 8) bytes
destThe destination unpacked array, of size (n * 2) bytes
vwThe virtual width of elements, that is the number of useful bits for each of them
nThe number of elements (in particular, of the destination array), NOT a length in bytes
Precondition
vw is expected to be >= 8.

Definition at line 330 of file cameras.c.

static void convert_uyvy_to_rgb ( uint8_t raw_buf,
uint8_t proc_buf,
freenect_frame_mode  frame_mode 
)
static

Definition at line 420 of file cameras.c.

static void depth_process ( freenect_device dev,
uint8_t pkt,
int  len 
)
static

Definition at line 377 of file cameras.c.

FN_INTERNAL int freenect_camera_init ( freenect_device dev)

Definition at line 1243 of file cameras.c.

FN_INTERNAL int freenect_camera_teardown ( freenect_device dev)

Definition at line 1267 of file cameras.c.

static int freenect_fetch_reg_const_shift ( freenect_device dev)
static

Definition at line 769 of file cameras.c.

static int freenect_fetch_reg_info ( freenect_device dev)
static

Definition at line 664 of file cameras.c.

static int freenect_fetch_reg_pad_info ( freenect_device dev)
static

Definition at line 742 of file cameras.c.

static int freenect_fetch_zero_plane_info ( freenect_device dev)
static

Definition at line 794 of file cameras.c.

freenect_frame_mode freenect_find_depth_mode ( freenect_resolution  res,
freenect_depth_format  fmt 
)

Convenience function to return a mode descriptor matching the specified resolution and depth camera pixel format, if one exists.

Parameters
resResolution desired
fmtPixel format desired
Returns
A freenect_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect_frame_mode.

Definition at line 1194 of file cameras.c.

freenect_frame_mode freenect_find_video_mode ( freenect_resolution  res,
freenect_video_format  fmt 
)

Convenience function to return a mode descriptor matching the specified resolution and video camera pixel format, if one exists.

Parameters
resResolution desired
fmtPixel format desired
Returns
A freenect_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect_frame_mode.

Definition at line 1131 of file cameras.c.

freenect_frame_mode freenect_get_current_depth_mode ( freenect_device dev)

Get the frame descriptor of the current depth mode for the specified freenect device.

Parameters
devWhich device to return the currently-set depth mode for
Returns
A freenect_frame_mode describing the current depth mode of the specified device

Definition at line 1189 of file cameras.c.

freenect_frame_mode freenect_get_current_video_mode ( freenect_device dev)

Get the frame descriptor of the current video mode for the specified freenect device.

Parameters
devWhich device to return the currently-set video mode for
Returns
A freenect_frame_mode describing the current video mode of the specified device

Definition at line 1126 of file cameras.c.

freenect_frame_mode freenect_get_depth_mode ( int  mode_num)

Get the frame descriptor of the nth supported depth mode for the depth camera.

Parameters
mode_numWhich of the supported modes to return information about
Returns
A freenect_frame_mode describing the nth depth mode

Definition at line 1180 of file cameras.c.

int freenect_get_depth_mode_count ( )

Get the number of depth camera modes supported by the driver. This includes both RGB and IR modes.

Returns
Number of depth modes supported by the driver

Definition at line 1175 of file cameras.c.

freenect_frame_mode freenect_get_video_mode ( int  mode_num)

Get the frame descriptor of the nth supported video mode for the video camera.

Parameters
mode_numWhich of the supported modes to return information about
Returns
A freenect_frame_mode describing the nth video mode

Definition at line 1117 of file cameras.c.

int freenect_get_video_mode_count ( )

Get the number of video camera modes supported by the driver. This includes both RGB and IR modes.

Returns
Number of video modes supported by the driver

Definition at line 1112 of file cameras.c.

int freenect_set_depth_buffer ( freenect_device dev,
void *  buf 
)

Set the buffer to store depth information to. Size of buffer is dependant on depth format. See FREENECT_DEPTH_*_SIZE defines for more information.

Parameters
devDevice to set depth buffer for.
bufBuffer to store depth information to.
Returns
0 on success, < 0 on error

Definition at line 1233 of file cameras.c.

void freenect_set_depth_callback ( freenect_device dev,
freenect_depth_cb  cb 
)

Set callback for depth information received event

Parameters
devDevice to set callback for
cbFunction pointer for processing depth information

Definition at line 1091 of file cameras.c.

void freenect_set_depth_chunk_callback ( freenect_device dev,
freenect_chunk_cb  cb 
)

Set callback for depth chunk processing

Parameters
devDevice to set callback for
cbFunction pointer for processing depth chunk

Definition at line 1102 of file cameras.c.

int freenect_set_depth_mode ( freenect_device dev,
const freenect_frame_mode  mode 
)

Sets the current depth mode for the specified device. The mode cannot be changed while streaming is active.

Parameters
devDevice for which to set the depth mode
modeFrame mode to set
Returns
0 on success, < 0 if error

Definition at line 1207 of file cameras.c.

int freenect_set_video_buffer ( freenect_device dev,
void *  buf 
)

Set the buffer to store depth information to. Size of buffer is dependant on video format. See FREENECT_VIDEO_*_SIZE defines for more information.

Parameters
devDevice to set video buffer for.
bufBuffer to store video information to.
Returns
0 on success, < 0 on error

Definition at line 1238 of file cameras.c.

void freenect_set_video_callback ( freenect_device dev,
freenect_video_cb  cb 
)

Set callback for video information received event

Parameters
devDevice to set callback for
cbFunction pointer for processing video information

Definition at line 1096 of file cameras.c.

void freenect_set_video_chunk_callback ( freenect_device dev,
freenect_chunk_cb  cb 
)

Set callback for video chunk processing

Parameters
devDevice to set callback for
cbFunction pointer for processing video chunk

Definition at line 1107 of file cameras.c.

int freenect_set_video_mode ( freenect_device dev,
freenect_frame_mode  mode 
)

Sets the current video mode for the specified device. If the freenect_frame_mode specified is not one provided by the driver e.g. from freenect_get_video_mode() or freenect_find_video_mode() then behavior is undefined. The current video mode cannot be changed while streaming is active.

Parameters
devDevice for which to set the video mode
modeFrame mode to set
Returns
0 on success, < 0 if error

Definition at line 1144 of file cameras.c.

int freenect_start_depth ( freenect_device dev)

Start the depth information stream for a device.

Parameters
devDevice to start depth information stream for.
Returns
0 on success, < 0 on error

Definition at line 841 of file cameras.c.

int freenect_start_video ( freenect_device dev)

Start the video information stream for a device.

Parameters
devDevice to start video information stream for.
Returns
0 on success, < 0 on error

Definition at line 901 of file cameras.c.

int freenect_stop_depth ( freenect_device dev)

Stop the depth information stream for a device

Parameters
devDevice to stop depth information stream on.
Returns
0 on success, < 0 on error

Definition at line 1048 of file cameras.c.

int freenect_stop_video ( freenect_device dev)

Stop the video information stream for a device

Parameters
devDevice to stop video information stream on.
Returns
0 on success, < 0 on error

Definition at line 1070 of file cameras.c.

static void stream_freebufs ( freenect_context ctx,
packet_stream strm 
)
static

Definition at line 260 of file cameras.c.

static void stream_init ( freenect_context ctx,
packet_stream strm,
int  rlen,
int  plen 
)
static

Definition at line 231 of file cameras.c.

static int stream_process ( freenect_context ctx,
packet_stream strm,
uint8_t pkt,
int  len,
freenect_chunk_cb  cb,
void *  user_data 
)
static

Definition at line 87 of file cameras.c.

static int stream_setbuf ( freenect_context ctx,
packet_stream strm,
void *  pbuf 
)
static

Definition at line 272 of file cameras.c.

static void video_process ( freenect_device dev,
uint8_t pkt,
int  len 
)
static

Definition at line 617 of file cameras.c.

Variable Documentation

const freenect_frame_mode invalid_mode = {0, (freenect_resolution)0, {(freenect_video_format)0}, 0, 0, 0, 0, 0, 0, 0}
static

Definition at line 74 of file cameras.c.

freenect_frame_mode supported_depth_modes[depth_mode_count]
static
freenect_frame_mode supported_video_modes[video_mode_count]
static
Initial value:
= {
}
#define MAKE_RESERVED(res, fmt)
Definition: cameras.c:37

Definition at line 42 of file cameras.c.



libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Mon Jun 10 2019 13:46:43