问题
I am trying to connect a FLIR cammera and process the frames using OpenCV. I connect the cammera with an internet cable but the VideoCapture object was not associated to cam successfully;
cv::VideoCapture cam(0);
if (cam.isOpened() == false) {
std::cout << "error: capWebcam not accessed successfully\n\n";
_getch();
return(0);
}
It looks like OpenCv can´t find it. The internet cable serves and as a power supply for the cammera just mentioning if maybe that's relavant. I can use the Spinnaker SDK to retrive the frames but is there someway not to use the sdk and use direcly OpenCV
回答1:
Ok for anyone that would be interested in the future on how to work in OpenCv with imagies acquired from PointGray cameras:
The industrial cameras have their proprietary drivers, they don't use the standard video interfaces of the OS. This is normal, as these cameras are quite complex and they are generally used in more complex situations, where you need a full control over the camera.
You have to download the camera's SDK from the Point Grey site (https://www.ptgrey.com/support/downloads) and implement the capturing yourself.
Then you can transform the captured buffer into an OpenCV Mat.
int ConvertToCVmat(ImagePtr pImage)
{
int result = 0;
ImagePtr convertedImage = pImage->Convert(PixelFormat_BGR8, NEAREST_NEIGHBOR);
unsigned int XPadding = convertedImage->GetXPadding();
unsigned int YPadding = convertedImage->GetYPadding();
unsigned int rowsize = convertedImage->GetWidth();
unsigned int colsize = convertedImage->GetHeight();
//image data contains padding. When allocating Mat container size, you need to account for the X,Y image data padding.
Mat cvimg = cv::Mat(colsize + YPadding, rowsize + XPadding, CV_8UC3, convertedImage->GetData(), convertedImage->GetStride());
namedWindow("current Image", CV_WINDOW_AUTOSIZE);
imshow("current Image", cvimg);
resizeWindow("current Image", rowsize / 2, colsize / 2);
waitKey(1);//otherwise the image will not display...
return result;
}
Also this is helpfull https://www.ptgrey.com/tan/10861
回答2:
cv::VideoCapture cam(0); is for cameras that install on PC see if you can open with VLC or any other application you may need to open VideoCapture with RTSP connection to the camera
来源:https://stackoverflow.com/questions/55024360/retrive-frames-from-flir-cameras-using-opencv