示例#1
0
void CamField::Display(int width, int height)
{
	if(_gCapture) {
		boost::unique_lock<boost::mutex> imageLock(imageMutex);
		_ComputePixPerDeg(width, height, 1);
		imageLock.unlock();
	} else {
		_ComputePixPerDeg(width, height, 0);
		glColor3f(0.2, 0.2, 0.2);
	}
}
示例#2
0
uint8_t* WpiClient::getCurrentImage() {
    std::lock_guard<std::mutex> imageLock(m_imageMutex);
    std::lock_guard<std::mutex> extLock(m_extMutex);

    // If buffer is wrong size, reallocate it
    if (m_imgWidth != m_extWidth || m_imgHeight != m_extHeight) {
        m_extWidth = m_imgWidth;
        m_extHeight = m_imgHeight;
    }

    m_extBuf = m_pxlBuf;

    return &m_extBuf[0];
}
示例#3
0
void _StartCapture(CvCapture **capture, IplImage **image)
{
	IplImage *tempImage;
	try {
		while(1) {
			boost::unique_lock<boost::mutex> captureLock(captureMutex);
			if(*capture) tempImage = cvQueryFrame(*capture);
			else {
				cvReleaseImage(&tempImage);
				return;
			}
			captureLock.unlock();

			cvCvtColor(tempImage, tempImage, CV_BGR2RGB);
			boost::unique_lock<boost::mutex> imageLock(imageMutex);
			cvReleaseImage(image);
			*image = cvCloneImage(tempImage);
			ready = 1;
			imageLock.unlock();
		}
	} catch (const std::exception &e) {
		std::cout << e.what() << std::endl;
	}
}