Difference between revisions of "Упражнение 11. Компютърно зрение"

From Ilianko
Line 119: Line 119:
  
 
== връзки ==
 
== връзки ==
http://robocraft.ru/blog/computervision/435.html
+
[http://robocraft.ru/blog/computervision/435.html]
http://nashruddin.com/
+
 
 +
[http://nashruddin.com/]
 
[[Category:Компютърна периферия]]
 
[[Category:Компютърна периферия]]

Revision as of 20:06, 19 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;
}


sinaptic manager apache2 http://localhost/

sudo chmod 777 /var/www/index.html sudo chmod 777 /var/www/

<img src="test.jpg" /> cvSaveImage("/var/www/test.jpg" ,img, 0);


int main(int argc, char** argv)
{
  CvCapture* c1 = cvCaptureFromCAM(0);
  IplImage* img;
  IplImage* img1;
  IplImage* img2;
  IplImage* img3;
  
  cvGrabFrame( c1 );	
  img=cvRetrieveFrame(c1,0);
  img1=cvRetrieveFrame(c1,0);
  img2=cvRetrieveFrame(c1,0);
  img3=cvRetrieveFrame(c1,0);
 
/* get image properties */
int width  = img->width;
int height = img->height;



  cvAdd(img, img ,img , NULL); 
 
/* create new image for the grayscale version */
IplImage* bw = cvCreateImage( cvSize( width, height ), IPL_DEPTH_8U, 1 );

	   

  while(cvWaitKey(5) < 0)
  {
    
    
    img2 = img1;
    img1 = img;
     
    cvGrabFrame( c1 );	
    img=cvRetrieveFrame(c1,0);
    
   
   cvAddWeighted( img1, 0.33, img2, 0.33, 0, img3);
   cvAddWeighted( img, 1, img, 0.33, 0, img3); 

   cvCvtColor( img3, bw, CV_RGB2GRAY );
    cvCanny( bw, bw, 50, 100, 3 );


    cvShowImage( "c1", bw);
  }
 
  //destroy the window
  cvReleaseCapture(&c1);
  return 0;
}

връзки

[1]

[2]