Example #1
0
ia_image_t*
v4l_readimage                   (ia_v4l_t*              v,
                                 ia_image_t*            iaf)
{
    int fd = v->fd;

    for (;;) {
        if (v4l_read_frame (v, iaf))
            break;
        ia_usleep (10);
    }
    return iaf;
}
Example #2
0
int v4l_cam_value(char*  device_name) {
	int fd = open(device_name, O_RDWR | O_NONBLOCK /* required */);

	if (v4l_check_capabilities(fd)) {
		return -1;
	}

	if (v4l_check_format(fd)) {
		return -1;
	}

	if(v4l_check_avaible_shots(fd)) {
		return -1;
	}

	int buf_length = 0;
	char* image_memmory = NULL;
	if(v4l_mmap_frame(fd, &image_memmory, &buf_length)) {
		return -1;
	}

	if(v4l_start_capture(fd)) {
		v4l_stop_capture(fd, image_memmory, buf_length);
		return -1;
	}

	int res = 0;
	if(v4l_wait_shot(fd) == 0) {
		res = v4l_read_frame(fd, image_memmory, buf_length);
	}

	v4l_stop_capture(fd, image_memmory, buf_length);

	close(fd);
	if (res >= 0) {
		return (res * 10240.0) / 64.0; //64 - because auto
	}

	return res;
}