Ejemplo n.º 1
0
void ProcessFrame(uint8 *pRawImg)
{
	OSC_ERR err;
	enum EnBayerOrder enBayerOrder;
	
	err = OscCamGetBayerOrder(&enBayerOrder, 0, 0);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Error getting bayer order! (%d)\n", __func__, err);
		return;
	}
	
	/* Use a framework function to debayer the image. */
	err = OscVisDebayer(pRawImg, OSC_CAM_MAX_IMAGE_WIDTH, OSC_CAM_MAX_IMAGE_HEIGHT, enBayerOrder, data.u8ResultImage);
	if (err != SUCCESS)
	{
		OscLog(ERROR, "%s: Error debayering image! (%d)\n", __func__, err);
		return;
	}
	
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
	/* |                                                                 */
	/* |                    Add your code here                           */
	/* |                                                                 */
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
}
Ejemplo n.º 2
0
/*!
 * @brief This is the main loop which is called after the initialisation of the application.
 *
 * This loop alternately takes pictures and calls parts of the aplication to process the image, handle the valves and read and write configuration data.
 */
OSC_ERR mainLoop() {
	OSC_ERR err = SUCCESS;
	static uint8 greyBuffer[WIDTH_CAPTURE * HEIGHT_CAPTURE];
	static uint8 colorBuffer[3 * WIDTH_CAPTURE * HEIGHT_CAPTURE];
	
	loop {
		int num = 0;
		
		while (num < sizeof greyBuffer) {
			int num_read = read(0, greyBuffer + num, (sizeof greyBuffer) - num);
			
			if (num_read == 0) {
				fprintf(stderr, "Reached end of file.\n");
				return SUCCESS;
			} else if (num_read == -1) {
				fprintf(stderr, "Error: Error %d.\n", errno);
				return ! SUCCESS;
			}
			
			num += num_read;
		}
		
		err = OscVisDebayer(greyBuffer, WIDTH_CAPTURE, HEIGHT_CAPTURE, ROW_RGRG, colorBuffer);
		if (err == -1)
			return err;
		
		err = write(1, colorBuffer, sizeof colorBuffer);
		if (err == -1)
			return err;
	}
	
	return SUCCESS;
}