Difference between revisions of "Упражнение 11. Компютърно зрение"
From Ilianko
Line 21: | Line 21: | ||
-lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy | -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy | ||
+ | |||
+ | <code><pre> | ||
+ | |||
+ | #include <opencv/highgui.h> //OpenCV GUI functions ̄include <stdio.h> | ||
+ | #include <opencv/cv.h> //main OpenCV functions | ||
+ | |||
+ | |||
+ | int main(int argc, char** argv) | ||
+ | { | ||
+ | CvCapture* c1 = cvCaptureFromCAM(0); | ||
+ | IplImage* img = 0; | ||
+ | |||
+ | |||
+ | |||
+ | while(cvWaitKey(2) < 0) | ||
+ | { | ||
+ | cvGrabFrame( c1 ); | ||
+ | img=cvRetrieveFrame(c1,0); | ||
+ | cvShowImage( "c1", img); | ||
+ | } | ||
+ | |||
+ | //destroy the window | ||
+ | cvReleaseCapture(&c1); | ||
+ | return 0; | ||
+ | } | ||
+ | </pre><code> | ||
[[Category:Компютърна периферия]] | [[Category:Компютърна периферия]] |
Revision as of 13:15, 18 May 2011
Инсталация openCV
1. Инсталирайте cmake sudo apt-get install cmake
2. Инсталирайте библиотеката libgtk2.0-dev
sudo apt-get install libgtk2.0-dev
3. да се свали openCV 2.2 и разархивирайте в директория Downloads/OpenCV-2.2.0
4. Влезте в директорията
cd Downloads/OpenCV-2.2.0 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ./ make make install
export LD_LIBRARY_PATH=/home/lab/Downloads/OpenCV-2.2.0/lib:$LD_LIBRARY_PATH sudo ldconfig
-lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy
#include <opencv/highgui.h> //OpenCV GUI functions ̄include <stdio.h>
#include <opencv/cv.h> //main OpenCV functions
int main(int argc, char** argv)
{
CvCapture* c1 = cvCaptureFromCAM(0);
IplImage* img = 0;
while(cvWaitKey(2) < 0)
{
cvGrabFrame( c1 );
img=cvRetrieveFrame(c1,0);
cvShowImage( "c1", img);
}
//destroy the window
cvReleaseCapture(&c1);
return 0;
}