Exemplo n.º 1
0
static void _main_view_mousedown_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
{
	int result;
	main_view *main_view_data = data;
	int w, h;
	camera_state_e cur_state = CAMERA_STATE_NONE;

	Evas_Event_Mouse_Down *ev = event_info;
	INF("mousedown x: %d y: %d", ev->canvas.x, ev->canvas.y);

	evas_object_image_size_get(main_view_data->preview_canvas, &w, &h);
	INF("image size w: %d h: %d", w, h);

    if (main_view_data->camera_enabled)
    {
    	result = camera_get_state(main_view_data->camera, &cur_state);
    	if(CAMERA_ERROR_NONE == result)
    	{
            if(cur_state == CAMERA_STATE_PREVIEW)
            {
            	result = camera_start_capture(main_view_data->camera, _main_view_camera_capturing_cb, _main_view_camera_capture_completed_cb, data);
            	if(result == CAMERA_ERROR_NONE)
            	{
            		INF("start camera capture successful");
            		//INF("Can not start camera capture");
            	}
            }
            else if(cur_state == CAMERA_STATE_CAPTURED)
            {
            	INF("can not start capture current state CAMERA_STATE_CAPTURED");
            }
            else if(cur_state == CAMERA_STATE_CAPTURING)
            {
            	INF("can not start capture current state CAMERA_STATE_CAPTURING");
            }
    	}
    	else
    	{
    		ERR("Error getting camera state after click");
    	}
    }
    else
    {
        ERR("Camera hasn't been initialized.");
    }

}
Exemplo n.º 2
0
/* read the frame of camera from device buffer and handle it in callback function */
void camera_read_frame(CameraDevice *thiz, 
                       VideoCallBack camera_data_callback,
                       void *ctx)
{
    assert(thiz != NULL);

    if (thiz->streaming_state == STREAMING_OFF)
    {
        camera_start_capture(thiz);
    }

    if (camera_is_read_ready(thiz))
    {
        struct v4l2_buffer buf;
        memset(&buf, 0, sizeof(buf));
        buf.type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        buf.memory = V4L2_MEMORY_MMAP;

        if (xioctl(thiz->fd, VIDIOC_DQBUF, &buf) == -1)
        {
            perror("de-queue buffers failed");
            exit(EXIT_FAILURE);
        }

        if (camera_data_callback != NULL)
        {
            camera_data_callback(ctx, 
                    thiz->req_buf_info[buf.index].start, 
                    buf.bytesused);
        }

        if (xioctl(thiz->fd, VIDIOC_QBUF, &buf) == -1)
        {
            perror("queue buffers failed");
            exit(EXIT_FAILURE);
        }
    }
}