Hi,
I am trying to add the ‘cam_getFrame’ request message to the hello_pixy sample application.
From searching the code base the API appears to be:
“cam_getFrame”,
(ProcPtr)cam_getFrameChirp,
{CRP_INT8, CRP_INT16, CRP_INT16, CRP_INT16, CRP_INT16, END},
“Get a frame from the camera”
“@p mode one of the following CAM_GRAB_M0R0 (0x00), CAM_GRAB_M1R1 (0x11), CAM_GRAB_M1R2 (0x21)”
“@p xOffset x offset counting from left”
“@p yOffset y offset counting from top”
“@p width width of frame”
“@p height height of frame”
“@r 0 if success, negative if error”
“@r BA81 formatted data”
I have extended the libpixyusb example application ‘hello_pixy’ by adding the following code (also see attached file):
{
unsigned char pixels[307200];
uint8_t *frame = (uint8_t *)&pixels[0];
int32_t response;^M
int return_value, res;
response = 0;
return_value = pixy_command("cam_getFrame", // String id for remote procedure
0x01, 0x21, // mode
0x02, 0, // xoffset
0x02,0, // yoffset
0x02,640, // width
0x02,480, // height
0, // separator
&response, // pointer to mem address for return value
&pixels, // pointer to mem address for returned frame
0);
fprintf(stderr,"getFrame returned: %d - %d\n", return_value, response);
This code returns the following:
getFrame returned: -3 - -2
In other words, it fails. I have had success with other commands (cam_getMode, cam_setMode) that I have implemented in this manner.
I believe it has something to do with the returned memory buffer in this message …
Do I need to initialize a setting on the camera prior to getting frames?
Am I allocating memory for the image map correctly?
Am I passing the pointer to the image map properly?
In other words what am I doing wrong with ‘cam_getFrame’?
Thanks,
Chris