hello!
have camera basler aca640-90gm , raspberry pi rasbian.
need process images obtained camera.
makefile make , work. recive basler camera image, dont show window.
if uncoment code didnt make.
have camera basler aca640-90gm , raspberry pi rasbian.
need process images obtained camera.
code: select all
#include <iomanip> #include </opt/pylon5/include/pylon/pylonincludes.h> #include </home/pi/opencv-3.1.0/include/opencv/cv.h> #include </home/pi/opencv-3.1.0/include/opencv/highgui.h> #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <iostream> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include <opencv2/core/utility.hpp> using namespace pylon; using namespace std; using namespace cv; int main(int argc, char* argv[]) { // exit code of sample application. int exitcode = 0; // before using pylon methods, pylon runtime must initialized. pylon::pylonautoinitterm autoinitterm; pyloninitialize(); //namedwindow("grab image",window_autosize); try { // define constants. const uint32_t cwidth = 640; const uint32_t cheight = 480; const uint32_t cpadding = 10; const uint8_t csamplegrayvalue = 160; // smart pointer receive grab result data. cgrabresultptr ptrgrabresult; pylonautoinitterm autoinitterm; // try grab result. cout << endl << "waiting image grabbed." << endl; try { cinstantcamera camera( ctlfactory::getinstance().createfirstdevice()); cout << "id camera: " << camera.getdeviceinfo().getmodelname() << endl; camera.grabone( 1000, ptrgrabresult); } catch (const genericexception &e) { cerr << "could not grab image: " << endl << e.getdescription() << endl; } if ( ptrgrabresult->grabsucceeded() ) { // create pylon image. cpylonimage image; cimageformatconverter fc; fc.outputpixelformat = pixeltype_bgr8packed; fc.outputbitalignment = outputbitalignment_msbaligned; fc.convert(image, ptrgrabresult); //mat cv_img = cv::mat( //ptrgrabresult->getheight(), //ptrgrabresult->getwidth(), //cv_8uc3, //(uint8_t*)image.getbuffer() ); cout << "grabresult h = " << ptrgrabresult->getheight()<< endl; cout << "grabresult w = " << ptrgrabresult->getwidth()<< endl; cout << "getbuffer = " << image.getbuffer() << endl; //imshow ( "grab image", image); //waitkey(1); } } catch (const genericexception &e) { // error handling. cerr << "an exception occurred." << endl << e.getdescription() << endl; exitcode = 1; } // releases pylon resources. pylonterminate(); return exitcode; }
code: select all
# makefile basler pylon sample program .phony: clean # program build name := image1 # installation directories pylon pylon_root ?= /opt/pylon5 # build tools , flags ld := $(cxx) cppflags := $(shell $(pylon_root)/bin/pylon-config --cflags) -duse_gige cxxflags := #e.g., cxxflags=-g -o0 debugging ldflags := $(shell $(pylon_root)/bin/pylon-config --libs-rpath) ldlibs := $(shell $(pylon_root)/bin/pylon-config --libs) # rules building all: $(name) $(name): $(name).o $(ld) $(ldflags) -o $@ $^ $(ldlibs) $(name).o: $(name).cpp $(cxx) $(cppflags) $(cxxflags) -c -o $@ $< clean: $(rm) $(name).o $(name)
if uncoment code didnt make.
code: select all
namedwindow("grab image",window_autosize); mat cv_img = cv::mat( ptrgrabresult->getheight(), ptrgrabresult->getwidth(), cv_8uc3, (uint8_t*)image.getbuffer() ); imshow ( "grab image", image); waitkey(1);
raspberrypi
Comments
Post a Comment