Rev Author Line No. Line
178 kaklik 1 #include "colourspace.h"
2 #include "image_dc1394input.h"
3 #include "rgba.h"
4  
5 namespace mimas {
6  
7 template<>
8 void image_dc1394input< rgba< unsigned char > >::
9 read( image< rgba< unsigned char > > &img ) throw (mimasexception)
10 {
11 MMERROR( m_handle != NULL, mimasexception, ,
12 "Camera device was closed already." );
13 if ( m_bufferUsed ) {
14 dc1394_dma_done_with_buffer( &m_camera );
15 m_bufferUsed = false;
16 };
17  
18 // Perform image capture.
19 MMERROR( dc1394_dma_single_capture( &m_camera ) == DC1394_SUCCESS,
20 mimasexception, ,
21 "Failed capturing frame from firewire digital camera." );
22 m_bufferUsed = true;
23  
24 img.init( m_camera.frame_width, m_camera.frame_height );
25  
26 switch ( m_colourSpace ) {
27 case UYVY:
28 uyvy_to_rgba( (const char *)m_camera.capture_buffer,
29 m_camera.frame_width, m_camera.frame_height,
30 (char *)img.rawData() );
31 break;
32 case RGB24:
33 rgb_to_rgba( (const char *)m_camera.capture_buffer,
34 m_camera.frame_width, m_camera.frame_height,
35 (char *)img.rawData() ); break;
36 default:
37 assert( false );
38 MMERROR( false, mimasexception, ,
39 "Colour-grabbing with colourspace number " << m_colourSpace
40 << " not supported." );
41 };
42 }
43  
44 };