예제 #1
0
void Vision::OpenFlyCapCamera()
{
	FlyCapture2::Error error;
	FlyCapture2::CameraInfo camInfo;

	// Connect the camera
	error = flyCapCamera.Connect(0);
	if (error != FlyCapture2::PGRERROR_OK) {
		throw VisionException("Failed to connect to camera");
	}

	// Get the camera info and print it out
	error = flyCapCamera.GetCameraInfo(&camInfo);
	if (error != FlyCapture2::PGRERROR_OK) {
		throw VisionException("Failed to get camera info from camera");
	}
	cout << camInfo.vendorName << " " << camInfo.modelName << " "
			<< camInfo.serialNumber << endl;

	error = flyCapCamera.StartCapture();
	if (error == FlyCapture2::PGRERROR_ISOCH_BANDWIDTH_EXCEEDED) {
		throw VisionException("Bandwidth exceeded");
	} else if (error != FlyCapture2::PGRERROR_OK) {
		throw VisionException("Failed to start image capture");
	}
}
예제 #2
0
void Vision::GetFrameFromFlyCap(Mat& currentFrame)
 {
	// Get the image
	FlyCapture2::Image rawImage;
	FlyCapture2::Error error = flyCapCamera.RetrieveBuffer(&rawImage);
	if (error != FlyCapture2::PGRERROR_OK) {
		throw VisionException("capture error");
	}

	IplImage* image = ConvertImageToOpenCV(&rawImage);

	currentFrame = cv::cvarrToMat(image);

//	// convert to rgb
//	FlyCapture2::Image rgbImage;
//	rawImage.Convert(FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage);
//
//	// convert to OpenCV Mat
//	unsigned int rowBytes = (double) rgbImage.GetReceivedDataSize()
//			/ (double) rgbImage.GetRows();
//	currentFrame = Mat(rgbImage.GetRows(), rgbImage.GetCols(), CV_8UC3,
//			rgbImage.GetData(), rowBytes);
}
예제 #3
0
float DetectedLine::Distance()
{
	throw VisionException("Distance is not implemented for Gate");
}