66 m_sFilename += pFilename;
83 if (m_sFilename.length() > 0)
84 m_pCapture = cvCaptureFromFile(m_sFilename.c_str());
86 m_pCapture = cvCaptureFromCAM(m_nIndex);
90 cvSetCaptureProperty(m_pCapture, CV_CAP_PROP_FPS, 30);
91 cvSetCaptureProperty(m_pCapture, CV_CAP_PROP_FRAME_WIDTH, 640);
92 cvSetCaptureProperty(m_pCapture, CV_CAP_PROP_FRAME_HEIGHT, 480);
94 m_pIplImage = cvQueryFrame(m_pCapture);
101 cvReleaseCapture(&m_pCapture);
107 m_pIplImage = cvQueryFrame(m_pCapture);
112 if (!pImage || pImage->
width != m_pIplImage->width || pImage->
height != m_pIplImage->height)
115 if (m_pIplImage->depth != IPL_DEPTH_8U)
117 else if (m_pIplImage->nChannels != 1 && m_pIplImage->nChannels != 3)
125 unsigned char *input = (
unsigned char *) m_pIplImage->imageData;
126 unsigned char *output = pImage->
pixels;
130 memcpy(output, input, nBytes);
134 for (
int i = 0; i < nBytes; i += 3)
136 output[i] = input[i + 2];
137 output[i + 1] = input[i + 1];
138 output[i + 2] = input[i];
152 return m_pIplImage ? m_pIplImage->width : -1;
157 return m_pIplImage ? m_pIplImage->height : -1;
COpenCVCapture(int nIndex, const char *pFilename=0)
bool CaptureImage(CByteImage **ppImages)
ImageType
Enum specifying the supported image types.
bool FlipY(const CByteImage *pInputImage, CByteImage *pOutputImage)
Flips the rows in a CByteImage vertically and writes the result to a CByteImage.
ImageType type
The type of the image.
int width
The width of the image in pixels.
int height
The height of the image in pixels.
unsigned char * pixels
The pointer to the the pixels.
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
CByteImage::ImageType GetType()
int bytesPerPixel
The number of bytes used for encoding one pixel.