Home > Back-end >  Basler gige camera how to use opencv display image
Basler gige camera how to use opencv display image

Time:09-21

This is an example of an official, I head files, libraries are matched, can run,
But it direct call is the window of the pylon, now I'd like to use opencv window to display his

 # include & lt; Pylon/PylonIncludes. H> 
#include

//Namespace for using pylon objects.
Using the namespace Pylon;

//Namespace for using cout.
using namespace std;

//Number of images to be grabbed.
The static const uint32_t c_countOfImagesToGrab=100;

Int main (int arg c, char * argv [])
{
//The exit code of The sample application. The
Int exitCode=0;

//Automagically call PylonInitialize and PylonTerminate to ensure the pylon runtime system
//is initialized during the lifetime of this object.
Pylon: : PylonAutoInitTerm autoInitTerm;

Try
{
//Create an instant camera object with the camera device found first.
CInstantCamera camera (CTlFactory: : GetInstance () CreateFirstDevice ());

//Print the model name of the camera.
cout <"Using device" & lt;
//The parameter MaxNumBuffer can be 2 control The count of buffers
//allocated for grabbing. The default value of this parameter is 10.
Camera. MaxNumBuffer=5;

//Start the grabbing of c_countOfImagesToGrab images.
//The camera device is parameterized with a default configuration which
//sets up free - running continuous acquisition.
Camera. StartGrabbing (c_countOfImagesToGrab);

//This smart pointer will receive the grab the result data.
CGrabResultPtr ptrGrabResult;

//Camera. StopGrabbing () is called automatically by the RetrieveResult () method
//the when c_countOfImagesToGrab images have had retrieved.
While (camera. IsGrabbing ())
{
//Wait for an image and then retrieve it. A timeout of 5000 ms is 2.
Camera. RetrieveResult (5000, ptrGrabResult, TimeoutHandling_ThrowException);

//Image grabbed successfully?
If (ptrGrabResult - & gt; GrabSucceeded ())
{
//Access the image data.
cout <"SizeX:" & lt; cout <"SizeY:" & lt; Const uint8_t * pImageBuffer=(uint8_t *) ptrGrabResult - & gt; GetBuffer ();
cout <"The Gray value of the first pixel:" & lt; <(uint32_t) pImageBuffer [0]
//Display the grabbed image.
Pylon: : the DisplayImage (1, ptrGrabResult);
}
The else
{
cout <"Error:" & lt; }
}
}
The catch (GenICam: : GenericException & amp; E)
{
//Error handling.
Cerr & lt; <"An exception occurred." & lt; ExitCode=1;
}

//Comment on the following two lines to disable waiting on exit.
Cerr & lt; While (cin. The get ()!='\ n');

Return exitCode;
}


Opencv very concise the code shown below
 
# include "opencv2/imgproc/imgproc HPP"
# include "opencv2/highgui/highgui. HPP"
Using the namespace CV;
using namespace std;
Int main ()
{
//declare IplImage pointer
IplImage * pFrame=NULL;

//get camera
CvCapture * pCapture=cvCreateCameraCapture (0);
//CvCapture * pCapture2=cvCreateCameraCapture (0);

//create a window
CvNamedWindow (" camera ", 1);

//display video
While (1)
{
PFrame=cvQueryFrame (pCapture);
if(! PFrame)
break;
CvShowImage (" camera, "pFrame);

Char c=cvWaitKey (33);
If (c==27)
break;
}
CvReleaseCapture (& amp; PCapture);
CvDestroyWindow (" camera ");
return 0;
}

CodePudding user response:

#include
#include
#include
Opencv header file is this a few, just is sticky, glad to please the great god,
I drive to pylon just contact, the company have to worry, also only I a person to make this a difficult problem, therefore, the Internet is no other example can refer to, can only wait for the great god appeared

CodePudding user response:

#include
#include
#include
Is this a few opencv head file

CodePudding user response:

Access is a computer camera, rather than basler camera

CodePudding user response:

The building Lord, I also need to do this recently, can you add a QQ, I want to ask you,

CodePudding user response:

Use CvvImage DrawToHDC function of a class, the camera picture shows that had been collected on the specified picture controls,,

CodePudding user response:

Hello the building Lord, how to configure the pylon header files, libraries, oneself the along while not back, good try so hard

CodePudding user response:

Since ptrGrabResult - & gt; GetBuffer () can get the captured image buffer, that you put it onto any surface can,

CodePudding user response:

The building Lord you solved? Can you tell me how to get?

CodePudding user response:

I also am this problem, waiting for the great godnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related