discoverpixy
Functions
Pixy Frame Helper
Collaboration diagram for Pixy Frame Helper:

Functions

int pixy_render_full_frame (uint16_t x, uint16_t y)
 
int pixy_render_cropped_frame (uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
 
int pixy_save_full_frame (FILE_HANDLE *handle)
 
int pixy_save_cropped_frame (FILE_HANDLE *handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
 
int pixy_cc_set_region (uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
 

Detailed Description

A collection of helper functions that allow receiving and rendering a frame from pixy onto the display. Furthermore you can select a color in a frame, to use for tracking.

Function Documentation

int pixy_cc_set_region ( uint8_t  signum,
uint16_t  xoffset,
uint16_t  yoffset,
uint16_t  width,
uint16_t  height 
)

Sets the color signature to the color in the selected region of the frame

Parameters
signumthe color signature number (1..7)
xoffsetThe x-Coordinate of the topleft point of the region
yoffsetThe y-Coordinate of the topleft point of the region
widthThe width of the region
heightThe height of the region
Returns
0 on success, otherwise the errorcode from pixy

Definition at line 233 of file pixy_frame.c.

234 {
235  int32_t response;
236 
237  int return_value = pixy_command("cc_setSigRegion", // String id for remote procedure
238  INT32(0), // type = normal color code
239  INT8(signum),
240  INT16(xoffset), // xoffset
241  INT16(yoffset), // yoffset
242  INT16(width), // width
243  INT16(height), // height
244  END_OUT_ARGS, // separator
245  &response, // pointer to mem address for return value
246  END_IN_ARGS);
247  return return_value;
248 }
#define INT16(v)
Definition: pixydefs.h:63
#define INT32(v)
Definition: pixydefs.h:65
int pixy_command(const char *name,...)
Send a command to Pixy.
uint16_t height
Definition: pixy.h:83
uint16_t width
Definition: pixy.h:82
#define END_OUT_ARGS
Definition: pixydefs.h:89
#define END_IN_ARGS
Definition: pixydefs.h:90
#define INT8(v)
Definition: pixydefs.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

int pixy_render_cropped_frame ( uint16_t  x,
uint16_t  y,
uint16_t  xoffset,
uint16_t  yoffset,
uint16_t  width,
uint16_t  height 
)

Receives a cropped frame from pixy and display's it on the display with the topleft corner at (x,y)

Parameters
xThe x-Coordinate of the top left corner to draw the image
yThe y-Coordinate of the top left corner to draw the image
xoffsetThe x-Coordinate on the pixy image from where on you want the frame data
yoffsetThe y-Coordinate on the pixy image from where on you want the frame data
widthThe width of the image recorded from pixy
heightThe height of the image recorded from pixy
Returns
0 on success, otherwise the errorcode from pixy

Definition at line 31 of file pixy_frame.c.

32 {
33  uint8_t* videodata;
34  int32_t response;
35  int32_t fourccc;
36  int8_t renderflags;
37  uint16_t xwidth;
38  uint16_t ywidth;
39  uint32_t size;
40 
41 
42  int return_value = pixy_command("cam_getFrame", // String id for remote procedure
43  INT8(0x21), // mode
44  INT16(xoffset), // xoffset
45  INT16(yoffset), // yoffset
46  INT16(width), // width
47  INT16(height), // height
48  END_OUT_ARGS, // separator
49  &response, // pointer to mem address for return value
50  &fourccc,
51  &renderflags,
52  &xwidth,
53  &ywidth,
54  &size,
55  &videodata, // pointer to mem address for returned frame
56  END_IN_ARGS);
57 
58  if (return_value == 0) {
59  return_value = renderBA81(x, y, xwidth, ywidth, size, videodata);
60  }
61 
62  return return_value;
63 }
static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
Definition: pixy_frame.c:139
#define INT16(v)
Definition: pixydefs.h:63
uint16_t y
Definition: pixy.h:81
int pixy_command(const char *name,...)
Send a command to Pixy.
uint16_t height
Definition: pixy.h:83
uint16_t width
Definition: pixy.h:82
#define END_OUT_ARGS
Definition: pixydefs.h:89
uint16_t x
Definition: pixy.h:80
#define END_IN_ARGS
Definition: pixydefs.h:90
#define INT8(v)
Definition: pixydefs.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

int pixy_render_full_frame ( uint16_t  x,
uint16_t  y 
)

Receives a fullsized frame from pixy and display's it on the display with the topleft corner at (x,y)

Parameters
xThe x-Coordinate of the top left corner
yThe y-Coordinate of the top left corner
Returns
0 on success, otherwise the errorcode from pixy

Definition at line 25 of file pixy_frame.c.

26 {
27  return pixy_render_cropped_frame(x, y, 0, 0, 320, 200);
28 }
uint16_t y
Definition: pixy.h:81
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:31
uint16_t x
Definition: pixy.h:80

Here is the call graph for this function:

Here is the caller graph for this function:

int pixy_save_cropped_frame ( FILE_HANDLE handle,
uint16_t  xoffset,
uint16_t  yoffset,
uint16_t  width,
uint16_t  height 
)

Receives a cropped frame from pixy and saves it to the given file in the 24bit (b,g,a) format.

Parameters
handleThe file to write the data to. The file must be open and it should be seeked to the right position.
xoffsetThe x-Coordinate on the pixy image from where on you want the frame data
yoffsetThe y-Coordinate on the pixy image from where on you want the frame data
widthThe width of the image recorded from pixy
heightThe height of the image recorded from pixy
Returns
0 on success, otherwise the errorcode from pixy

Definition at line 70 of file pixy_frame.c.

71 {
72  uint8_t* videodata;
73  int32_t response;
74  int32_t fourccc;
75  int8_t renderflags;
76  uint16_t xwidth;
77  uint16_t ywidth;
78  uint32_t size;
79 
80 
81  int return_value = pixy_command("cam_getFrame", // String id for remote procedure
82  INT8(0x21), // mode
83  INT16(xoffset), // xoffset
84  INT16(yoffset), // yoffset
85  INT16(width), // width
86  INT16(height), // height
87  END_OUT_ARGS, // separator
88  &response, // pointer to mem address for return value
89  &fourccc,
90  &renderflags,
91  &xwidth,
92  &ywidth,
93  &size,
94  &videodata, // pointer to mem address for returned frame
95  END_IN_ARGS);
96 
97  if (return_value == 0) {
98  return_value = saveBA81(handle, xwidth, ywidth, size, videodata);
99  }
100 
101  return return_value;
102 }
static int saveBA81(FILE_HANDLE *handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
Definition: pixy_frame.c:189
#define INT16(v)
Definition: pixydefs.h:63
int pixy_command(const char *name,...)
Send a command to Pixy.
uint16_t height
Definition: pixy.h:83
uint16_t width
Definition: pixy.h:82
#define END_OUT_ARGS
Definition: pixydefs.h:89
#define END_IN_ARGS
Definition: pixydefs.h:90
#define INT8(v)
Definition: pixydefs.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

int pixy_save_full_frame ( FILE_HANDLE handle)

Receives a fullsized frame from pixy and saves it to the given file in the 24bit (b,g,a) format. Use this method to write the bitmap-data part of a windows bitmap (.bmp). This method will neither open nor close the passed file.

Parameters
handleThe file to write the data to. The file must be open and it should be seeked to the right position.
Returns
0 on success, otherwise the errorcode from pixy

Definition at line 65 of file pixy_frame.c.

66 {
67  return pixy_save_cropped_frame(handle, 0, 0, 320, 200);
68 }
int pixy_save_cropped_frame(FILE_HANDLE *handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:70

Here is the call graph for this function:

Here is the caller graph for this function: