59 #define UYVY 0x59565955 60 #define FOURCC(a,b,c,d) (unsigned int)((((unsigned int)d)<<24)+(((unsigned int)c)<<16)+(((unsigned int)b)<<8)+a) 91 unicap_property_t property;
93 unicap_format_t format_spec;
95 int nCamerasFound = 0;
98 for (
int i = 0; i < 10; i++)
100 if (SUCCESS(unicap_enumerate_devices(0, &
device[i], i)))
102 printf(
"info: camera found at index %i\n", i);
103 printf(
"info: using device for cam: %s\n",
device[i].identifier);
113 unicap_void_property( &property );
114 strcpy( property.identifier,
"video norm" );
115 unicap_get_property(
handle[i], &property );
116 strcpy( property.menu_item, property.menu.menu_items[this->norm] );
117 if(!SUCCESS(unicap_set_property(
handle[i], &property)))
123 unicap_void_property( &property );
124 strcpy( property.identifier,
"source" );
125 unicap_get_property(
handle[i], &property );
126 strcpy( property.menu_item, property.menu.menu_items[this->source] );
127 if(!SUCCESS(unicap_set_property(
handle[i], &property)))
133 if(!SUCCESS(unicap_lock_stream(
handle[i])))
139 unicap_status_t status=0;
140 unicap_void_format( &format_spec );
142 format_spec.fourcc =
FOURCC(
'U',
'Y',
'V',
'Y');
144 status = unicap_enumerate_formats(
handle[i], &format_spec, &format, 0 );
147 printf(
"error: failed get video format\n");
151 for (
int j = 0; j < format.size_count; j++)
153 printf(
"format %i: width/height = %i/%i\n", j, format.sizes[j].width, format.sizes[j].height);
158 if (format.sizes[j].width == 320 && format.sizes[j].height == 240)
167 if (format.sizes[j].width == 640 && format.sizes[j].height == 480)
176 if (format.sizes[j].width == 768 && format.sizes[j].height == 576)
188 printf(
"error: could not found matching mode\n");
192 printf(
"info: took format %i with resolution %i/%i\n", num,
width,
height);
194 format.size.width = format.sizes[
num].width;
195 format.size.height = format.sizes[
num].height;
197 if(!SUCCESS( unicap_set_format(
handle[i], &format ) ) )
199 printf(
"error: Failed to set video format\n" );
202 if( !SUCCESS( unicap_get_format(
handle[i], &format ) ) )
204 printf(
"error: Failed to get video format\n" );
207 memset(&
buffer[i], 0x0,
sizeof(unicap_data_buffer_t));
209 buffer[i].buffer_size = format.buffer_size;
210 buffer[i].type = format.buffer_type;
212 printf(
"info: %s->Buffer size: %d\n",
device[i].identifier,format.buffer_size);
214 if (
buffer[i].
type == UNICAP_BUFFER_TYPE_USER)
215 buffer[i].data =
new unsigned char[
buffer[i].buffer_size];
217 status = unicap_start_capture(
handle[i]);
220 printf(
"error: failed to start capture on device: %s (Error Code : %x)\n",
device[i].identifier,status );
242 if (!unicap_stop_capture(
handle[i]))
243 printf(
"error: close\n");
245 unicap_unlock_stream(
handle[i]);
247 if(!SUCCESS(unicap_close(
handle[i])))
249 printf(
"error: destructor\n");
262 float u,y1,
v,y2,r1,g1,b1,r2,g2,b2;
264 for(
unsigned int i = 0,j=0; i<nBytes;i+=4,j+=6)
276 r1 = 1.164f * y1 + 1.596f *
v;
277 g1 = 1.164f * y1 - 0.392f * u - 0.813f *
v;
278 b1 = 1.164f * y1 + 2.017f * u;
280 r2 = 1.164f * y2 + 1.596f *
v;
281 g2 = 1.164f * y2 - 0.392f * u - 0.813f *
v;
282 b2 = 1.164f * y2 + 2.017f * u;
288 if (r1 > 255) r1 = 255;
289 if (g1 > 255) g1 = 255;
290 if (b1 > 255) b1 = 255;
295 if (r2 > 255) r2 = 255;
296 if (g2 > 255) g2 = 255;
297 if (b2 > 255) b2 = 255;
299 output[j] = (
unsigned char)r1;
300 output[j+1]= (
unsigned char)g1;
301 output[j+2]= (
unsigned char)b1;
302 output[j+3]= (
unsigned char)r2;
303 output[j+4]= (
unsigned char)g2;
304 output[j+5]= (
unsigned char)b2;
310 unicap_data_buffer_t *returned_buffer[10] = { 0 };
314 unicap_status_t status = unicap_queue_buffer(
handle[i], &
buffer[i]);
317 printf(
"error: failed to queue a buffer on device: %s (Error Code : %x)\n",
device[i].identifier,status);
321 status = unicap_wait_buffer(
handle[i], &returned_buffer[i]);
323 if (!SUCCESS(status))
325 printf(
"error: %x\n", status);
326 printf(
"error: failed to wait for buffer on device: %s (Error Code : %x)\n",
device[i].identifier,status );
unicap_device_t device[UNICAP_MAX_CAMERAS]
unicap_handle_t handle[UNICAP_MAX_CAMERAS]
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
GLuint GLuint GLsizei GLenum type
#define FOURCC(a, b, c, d)
CUnicap1394Capture(int nCameras, VideoMode mode)
#define UNICAP_MAX_CAMERAS
void Convert(const unsigned char *input, unsigned char *output)
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
GLenum GLsizei GLsizei height
GLenum GLenum GLenum input
bool CaptureImage(CByteImage **ppImages)
GLsizei GLsizei GLchar * source
GLenum GLsizei GLenum format