Build A/C + + compilation environment: sudo apt-get install build-essential
Install the correlation library: sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev py Thon-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev-y
Download good Linux source to the official website and pull to ubuntu14.04 virtual machine to unzip and enter the OpenCV directory, switch to root permission
CMake.
Make
Make install
Three was done, but the make process took a long time. Note that there is a space and a dot behind the cmake above.
Next is the test code, VI img.cpp
/*compile command:g++ img.cpp-lopencv_highgui-lopencv_videoio-lopencv_imgcodecs-o img*/#include<opencv/highgui.h>#include<stdio.h>//using namespace std;//using namespace CV;#defineImage_width 320#defineImage_height 240intMain () {Iplimage*img; Cvcapture* Cap = Cvcreatecameracapture (0); Cvsetcaptureproperty (Cap, cv_cap_prop_frame_width, image_width); Cvsetcaptureproperty (Cap, cv_cap_prop_frame_height, image_height); IMG=cvqueryframe (CAP); printf ("width:%d\t height:%d\t widthstep:%d\n", Img->width, Img->height, img->widthstep); Cvsaveimage ("img.jpg", IMG); return 0;}
Compilation: g++ img.cpp-lopencv_highgui-lopencv_videoio-lopencv_imgcodecs-o img
Execution:./img
You can get a picture of a given resolution img.jpg.
opencv3.0 compilation installation (ubuntu14.04 system), OPENCV set camera resolution and capture picture