99 m_nCameras = nCameras;
105 m_bFormat7Mode =
false;
107 if(m_nInstances == 0)
112 m_pCameraOpener[i] = NULL;
123 m_sCameraUID[i] =
"";
127 va_start(ap, nNumberUIDs);
129 for(
int u = 0 ; u < nNumberUIDs ; u++)
131 const char* pch = va_arg(ap,
const char*);
132 m_sCameraUID[u] += pch;
133 transform(m_sCameraUID[u].begin(), m_sCameraUID[u].
end(), m_sCameraUID[u].begin(), (
int(*)(
int)) toupper);
144 m_nCameras = nNumberUIDs;
150 m_bFormat7Mode =
false;
152 if(m_nInstances == 0)
157 m_pCameraOpener[i] = NULL;
171 m_mode(
mode), m_colorMode(colorMode), m_bayerPatternType(bayerPatternType)
179 m_nCameras = nCameras;
184 m_bFormat7Mode =
true;
185 m_nFormat7PacketSize = nFormat7PacketSize == -1 ? USE_MAX_AVAIL : nFormat7PacketSize;
186 m_nFormat7MinX = nFormat7MinX;
187 m_nFormat7MinY = nFormat7MinY;
188 m_nFormat7Width = nFormat7Width;
189 m_nFormat7Height = nFormat7Height;
193 if (m_nInstances == 0)
198 m_pCameraOpener[i] = NULL;
207 m_mode(
mode), m_colorMode(colorMode), m_bayerPatternType(bayerPatternType)
211 m_sCameraUID[i] =
"";
215 va_start(ap, nNumberUIDs);
217 for(
int u = 0 ; u < nNumberUIDs ; u++)
219 const char* pch = va_arg(ap,
const char*);
220 m_sCameraUID[u] += pch;
221 transform(m_sCameraUID[u].begin(), m_sCameraUID[u].
end(), m_sCameraUID[u].begin(), (
int(*)(
int)) toupper);
232 m_nCameras = nNumberUIDs;
237 m_bFormat7Mode =
true;
238 m_nFormat7PacketSize = nFormat7PacketSize == -1 ? USE_MAX_AVAIL : nFormat7PacketSize;
239 m_nFormat7MinX = nFormat7MinX;
240 m_nFormat7MinY = nFormat7MinY;
241 m_nFormat7Width = nFormat7Width;
242 m_nFormat7Height = nFormat7Height;
245 m_bFormat7Mode =
true;
247 if (m_nInstances == 0)
252 m_pCameraOpener[i] = NULL;
286 m_nOverallCameras = 0;
298 printf(
"error: selected camera mode not supported\n");
314 bool bOpened =
false;
321 printf(
"error: camera with UID 0x%s already opened\n",
m_sCameraUID[
c].c_str());
335 printf(
"error: could not find camera with UID 0x%s\n",
m_sCameraUID[
c].c_str());
341 int nNumberCameras = 0;
360 if(nNumberCameras == 0)
362 printf(
"error: no camera found\n");
371 printf(
"error: could not open requested number of cameras\n");
385 printf(
"Opening camera %d: Port %d, Index %d, UID 0x%s, Format7 = %i\n",nCamera,p,i,
m_CameraInfo[nCamera].sUID.c_str(),
m_bFormat7Mode);
387 char *device_name = 0;
391 if (dc1394_dma_setup_format7_capture(
m_handles[nCamera],
m_cameras[nCamera].node, i + 1, MODE_FORMAT7_0, SPEED_400,
m_nFormat7PacketSize,
m_nFormat7MinX,
m_nFormat7MinY,
m_nFormat7Width,
m_nFormat7Height,
NUM_BUFFERS,
DROP_FRAMES, device_name, &
m_cameras[nCamera]) != DC1394_SUCCESS)
393 printf(
"error: unable to setup camera (mode supported by camera?)\n");
400 if (dc1394_dma_setup_capture(
m_handles[nCamera],
m_cameras[nCamera].node, i + 1, FORMAT_VGA_NONCOMPRESSED,
m_video_mode, SPEED_400,
GetDCFrameRateMode(
m_frameRate),
NUM_BUFFERS,
DROP_FRAMES, device_name, &
m_cameras[nCamera]) != DC1394_SUCCESS)
402 printf(
"error: unable to setup camera (mode supported by camera?)\n");
409 if (dc1394_start_iso_transmission(
m_handles[nCamera],
m_cameras[nCamera].node) != DC1394_SUCCESS)
411 printf(
"error: unable to start camera iso transmission\n");
537 unsigned char* output = pOutput->
pixels;
540 for(
int i = 0 ; i <
height ; i++)
542 for(
int j = 0 ; j < width / 4 ; j++)
572 r = int(y + 1.370705 * v);
573 g = int(y - 0.698001 * v - 0.337633 * u);
574 b = int(y + 1.732446 * u);
580 if (r > 255) r = 255;
581 if (g > 255) g = 255;
582 if (b > 255) b = 255;
584 output[0] = (
unsigned char) r;
585 output[1] = (
unsigned char) g;
586 output[2] = (
unsigned char) b;
763 case e60fps:
return FRAMERATE_60;
764 case e30fps:
return FRAMERATE_30;
765 case e15fps:
return FRAMERATE_15;
766 case e7_5fps:
return FRAMERATE_7_5;
767 case e3_75fps:
return FRAMERATE_3_75;
770 default:
return FRAMERATE_30;
781 raw1394handle_t raw_handle = raw1394_new_handle();
784 printf(
"error: unable to aquire a raw1394 handle\n");
790 raw1394_destroy_handle(raw_handle);
791 printf(
"number of ports = %d\n",
m_nPorts);
799 raw_handle = raw1394_new_handle();
800 raw1394_set_port(raw_handle,
p);
802 raw1394_destroy_handle(raw_handle);
805 for (
int i = 0; i < camCount; i++)
810 printf(
"error: unable to aquire a raw1394 handle\n");
816 dc1394_feature_set features;
818 if (dc1394_get_camera_feature_set(
m_handles[m_nOverallCameras],
m_cameras[m_nOverallCameras].node, &features) != DC1394_SUCCESS)
820 printf(
"info: unable to get feature set\n");
827 unsigned int channel, speed;
829 if (dc1394_get_iso_channel_and_speed(
m_handles[m_nOverallCameras],
m_cameras[m_nOverallCameras].node, &channel, &speed) != DC1394_SUCCESS)
831 printf(
"error: unable to get the iso channel number\n");
837 dc1394_camerainfo info;
839 if (dc1394_get_camera_info(
m_handles[m_nOverallCameras],
m_cameras[m_nOverallCameras].node, &info) != DC1394_SUCCESS)
841 printf(
"error: unable to retrieve camera info\n");
847 unsigned int low = info.euid_64;
848 unsigned int high = (info.euid_64 >> 32);
854 printf(
"error: found more cameras than MAX_CAMERAS\n");
869 sprintf(szUID,
"%08X%08X\0",nHigh,nLow);
int m_nOpenedCameras[MAX_CAMERAS]
void ConvertYUV411(CByteImage *pInput, CByteImage *pOutput)
int GetDCFrameRateMode(FrameRate frameRate)
BayerPatternType
The four possible variants for Bayer pattern conversion.
CByteImage * m_pTempImageHeader
int width
The width of the image in pixels.
static TCameraInfo m_CameraInfo[MAX_CAMERAS]
static nodeid_t * m_pCameraNodes[MAX_PORTS]
bool ConvertBayerPattern(const CByteImage *pInputImage, CByteImage *pOutputImage, BayerPatternType type)
Converts an 8 bit Bayer pattern CByteImage to an RGB24 color CByteImage.
const ImageProcessor::BayerPatternType m_bayerPatternType
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
CLinux1394Capture(int nCameras, VideoMode mode, ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType=ImageProcessor::eBayerRG, FrameRate frameRate=e30fps)
const ColorMode m_colorMode
unsigned char * pixels
The pointer to the the pixels.
static dc1394_cameracapture m_cameras[MAX_CAMERAS]
static raw1394handle_t m_handles[MAX_CAMERAS]
void SetExposure(unsigned int nValue)
static int m_nOverallCameras
CByteImage::ImageType GetType()
bool CaptureImage(CByteImage **ppImages)
void SetShutter(unsigned int nValue)
bool CopyImage(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bUseSameSize=false)
Copies one CByteImage to another.
GLsizei const GLchar ** string
GLubyte GLubyte GLubyte a
int height
The height of the image in pixels.
std::string m_sCameraUID[MAX_CAMERAS]
int bytesPerPixel
The number of bytes used for encoding one pixel.
std::string CamUIDToString(unsigned int nLow, unsigned int nHigh)
GLenum GLsizei GLsizei height
ImageType
Enum specifying the supported image types.
static CLinux1394Capture * m_pCameraOpener[MAX_CAMERAS]
GLenum GLenum GLenum input
ImageType type
The type of the image.
void SetGain(unsigned int nValue)
GLdouble GLdouble GLdouble r
GLuint GLenum GLenum transform
void YUVToRGB(int y, int u, int v, unsigned char *output)
bool CaptureBayerPatternImage(CByteImage **ppImages)
CByteImage * m_pTempImage
bool Resize(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bInterpolation=true)
Resizes a CByteImage and writes the result to a CByteImage.