int32_t cam_getFrameChirp(const uint8_t &type, const uint16_t &xOffset, const uint16_t &yOffset, const uint16_t &xWidth, const uint16_t &yWidth, Chirp *chirp) { int32_t result, prebuf; uint8_t *frame = (uint8_t *)SRAM0_LOC; // force an error to get prebuf length CRP_RETURN(chirp, USE_BUFFER(SRAM0_SIZE, frame), HTYPE(0), UINT16(0), UINT16(0), UINTS8(0, 0), END); prebuf = chirp->getPreBufLen(); if ((result=cam_getFrame(frame+prebuf, SRAM0_SIZE-prebuf, type, xOffset, yOffset, xWidth, yWidth))>=0) // send frame, use in-place buffer CRP_RETURN(chirp, USE_BUFFER(SRAM0_SIZE, frame), HTYPE(FOURCC('B','A','8','1')), UINT16(xWidth), UINT16(yWidth), UINTS8(xWidth*yWidth, frame+prebuf), END); return result; }
int32_t cc_getRLSFrameChirp(Chirp *chirp) { int32_t result; uint32_t len, numRls; // figure out prebuf length (we need the prebuf length and the number of runlength segments, but there's a chicken and egg problem...) len = Chirp::serialize(chirp, RLS_MEMORY, RLS_MEMORY_SIZE, HTYPE(0), UINT16(0), UINT16(0), UINTS32_NO_COPY(0), END); result = cc_getRLSFrame((uint32_t *)(RLS_MEMORY+len), LUT_MEMORY, &numRls); // send frame, use in-place buffer Chirp::serialize(chirp, RLS_MEMORY, RLS_MEMORY_SIZE, HTYPE(FOURCC('C','C','Q','1')), UINT16(CAM_RES2_WIDTH), UINT16(CAM_RES2_HEIGHT), UINTS32_NO_COPY(numRls), END); // copy from IPC memory to RLS_MEMORY if (g_qqueue->readAll((Qval *)(RLS_MEMORY+len), (RLS_MEMORY_SIZE-len)/sizeof(Qval))!=numRls) return -1; chirp->useBuffer(RLS_MEMORY, len+numRls*4); return result; }
int32_t cam_getFrameChirpFlags(const uint8_t &type, const uint16_t &xOffset, const uint16_t &yOffset, const uint16_t &xWidth, const uint16_t &yWidth, Chirp *chirp, uint8_t renderFlags) { int32_t result, len; uint8_t *frame = (uint8_t *)SRAM1_LOC; // fill buffer contents manually for return data len = Chirp::serialize(chirp, frame, SRAM1_SIZE, HTYPE(FOURCC('B','A','8','1')), HINT8(renderFlags), UINT16(xWidth), UINT16(yWidth), UINTS8_NO_COPY(xWidth*yWidth), END); // write frame after chirp args result = cam_getFrame(frame+len, SRAM1_SIZE-len, type, xOffset, yOffset, xWidth, yWidth); // tell chirp to use this buffer chirp->useBuffer(frame, len+xWidth*yWidth); return result; }
void sendCustom(uint8_t renderFlags=RENDER_FLAG_FLUSH) { int32_t len; uint8_t *frame = (uint8_t *)SRAM1_LOC; uint32_t fcc; // fill buffer contents manually for return data len = Chirp::serialize(g_chirpUsb, frame, SRAM1_SIZE, HTYPE(FOURCC('B','A','8','1')), HINT8(renderFlags), UINT16(CAM_RES2_WIDTH), UINT16(CAM_RES2_HEIGHT), UINTS8_NO_COPY(CAM_RES2_WIDTH*CAM_RES2_HEIGHT), END); // write frame after chirp args cam_getFrame(frame+len, SRAM1_SIZE-len, CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT); //convolutionImage(CAM_RES2_WIDTH, CAM_RES2_HEIGHT, len, frame, true); //inverceImage(CAM_RES2_WIDTH, CAM_RES2_HEIGHT, len, frame); // tell chirp to use this buffer g_chirpUsb->useBuffer(frame, len+CAM_RES2_WIDTH*CAM_RES2_HEIGHT); // if (g_execArg==1) // { // cprintf("g_execArg==1"); // // fill buffer contents manually for return data // len = Chirp::serialize(g_chirpUsb, frame, SRAM1_SIZE, HTYPE(FOURCC('C','M','V','2')), HINT8(renderFlags), UINT16(CAM_RES2_WIDTH), UINT16(CAM_RES2_HEIGHT), UINTS8_NO_COPY(CAM_RES2_WIDTH*CAM_RES2_HEIGHT), END); // // write frame after chirp args // cam_getFrame(frame+len, SRAM1_SIZE-len, CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT); // //inverceImage(CAM_RES2_WIDTH, CAM_RES2_HEIGHT, len, frame); // // tell chirp to use this buffer // g_chirpUsb->useBuffer(frame, len+CAM_RES2_WIDTH*CAM_RES2_HEIGHT); // } // else if (100<=g_execArg && g_execArg<200) // { // cprintf("100<=g_execArg && g_execArg<200"); // fcc = FOURCC('E','X',(g_execArg%100)/10 + '0', (g_execArg%10) + '0'); // len = Chirp::serialize(g_chirpUsb, frame, SRAM1_SIZE, HTYPE(fcc), HINT8(renderFlags), UINT16(CAM_RES2_WIDTH), UINT16(CAM_RES2_HEIGHT), UINTS8_NO_COPY(CAM_RES2_WIDTH*CAM_RES2_HEIGHT), END); // // write frame after chirp args // cam_getFrame(frame+len, SRAM1_SIZE-len, CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT); // //inverceImage(CAM_RES2_WIDTH, CAM_RES2_HEIGHT, len, frame); // // tell chirp to use this buffer // g_chirpUsb->useBuffer(frame, len+CAM_RES2_WIDTH*CAM_RES2_HEIGHT); // } // else // { // cprintf("sendCustom else"); // cam_getFrameChirp(CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT, g_chirpUsb); // } }
int cc_sendBlobs(Chirp *chirp, const BlobA *blobs, uint32_t len, const BlobB *ccBlobs, uint32_t ccLen, uint8_t renderFlags) { CRP_RETURN(chirp, HTYPE(FOURCC('C','C','B','2')), HINT8(renderFlags), HINT16(CAM_RES2_WIDTH), HINT16(CAM_RES2_HEIGHT), UINTS16(len*sizeof(BlobA)/sizeof(uint16_t), blobs), UINTS16(ccLen*sizeof(BlobB)/sizeof(uint16_t), ccBlobs), END); return 0; }
int32_t cc_getRLSCCChirp(Chirp *chirp) { int16_t* c_components = new int16_t[MAX_BLOBS*4]; uint32_t numRls, result;//, prebuf; uint32_t *memory = (uint32_t *)RLS_MEMORY; result = cc_getRLSFrame(memory, LUT_MEMORY, &numRls); CBlobAssembler blobber; int32_t row; uint32_t i, startCol, length; uint8_t model; for (i=0, row=-1; i<numRls; i++) { if (memory[i]==0) { row++; continue; } model = memory[i]&0x03; memory[i] >>= 3; startCol = memory[i]&0x1ff; memory[i] >>= 9; length = memory[i]&0x1ff; if(!handleRL(&blobber, model, row, startCol, length)) break; } blobber.EndFrame(); blobber.SortFinished(); // // Take Finished blobs and return with chirp // CBlob *blob, *temp; blob = blobber.finishedBlobs; uint32_t cc_num = 0; temp = blob; while (temp) { int16_t top, right, bottom, left; temp->getBBox(left, top, right, bottom); // Don't want objects with area less than 9... if ((right-left)*(bottom-top) < 9) break; temp = temp->next; cc_num++; } // Remove the rest that we don't care about /*while(temp) { CBlob *next = temp->next; temp->~CBlob(); temp = NULL; temp = next; }*/ cc_num = (cc_num < 15) ? cc_num : MAX_BLOBS; // Populate return w/ result //void* mem = malloc(sizeof(int16_t)*cc_num*4); //if (mem == NULL) // int i = 0; //free(mem); //int16_t* c_components = new int16_t[cc_num*4]; //g_mem += sizeof(int16_t)*cc_num*4; memset((void *)c_components, 0, sizeof(uint16_t)*cc_num*4); for (int i = 0; i < cc_num; i++) { int16_t top, right, bottom, left; blob->getBBox(left, top, right, bottom); c_components[(i*4)+0] = top; c_components[(i*4)+1] = right; c_components[(i*4)+2] = bottom; c_components[(i*4)+3] = left; blob = blob->next; } //CRP_RETURN(chirp, USE_BUFFER(SRAM0_SIZE, SRAM0_LOC), HTYPE(0), UINT16(0), UINT16(0), UINTS8(0, 0), END); //prebuf = chirp->getPreBufLen(); blobber.Reset(); CRP_RETURN(chirp, HTYPE(FOURCC('V','I','S','U')), UINTS16(cc_num*4, c_components), END); delete[] c_components; //g_mem -= sizeof(int16_t)*cc_num*4; return result; }
void exec_sendEvent(Chirp *chirp, uint32_t event) { if (chirp) CRP_SEND_XDATA(chirp, HTYPE(FOURCC('E','V','T','1')), INT32(event)); }