To Log Everything I find useful. If you find anything inappropriate, please contact cuijinqiang@gmail.com
Thursday, June 14, 2012
WebCam in C++
#include <StdAfx.h>
#include <opencv.hpp>
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
namedWindow("edges",1);
namedWindow("original",2);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30,3);
imshow("edges", edges);
imshow("original", frame);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
Capture Webcam in C
// OpenCV1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
if ( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
// Create a window in which the captured images will be presented
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
// Show the image captured from the camera in the window and repeat
while ( 1 ) {
// Get one frame
IplImage* frame = cvQueryFrame( capture );
if ( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
cvShowImage( "mywindow", frame );
// Do not release the frame!
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if ( (cvWaitKey(10) & 255) == 27 ) break;
}
// Release the capture device housekeeping
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
}
Monday, June 11, 2012
Install OpenCV 2.4 with Visual Studio 2010
Download OpenCV 2.4
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/
Extract the files into a folder ‘D:\Software\opencv’
Copy the following things to a folder in C:\OpenCV2.4
D:\Software\opencv\build\x86\vc10
D:\Software\opencv\build\include
Add the follwoing into system variable.
C:\OpenCV2.4\bin;C:\OpenCV2.4\bin\Debug;C:\OpenCV2.4\bin\Release
Create a new project and add this to your project properties:
1. Go to VC++ Directories;
2. Add 3 new Include Directories (it's the path where you installed OpenCV, include folder):
C:\OpenCV2.4\include\
C:\OpenCV2.4\include\opencv
C:\OpenCV2.4\include\opencv2
3. Add 1 new Library Directory (it's the path where you installed OpenCV, lib folder):
C:\OpenCV2.4\lib
4. Go to Linker in the left menu and select Input option
5. Add these entries on Additional Dependencies option(debug)
C:\OpenCV2.4\lib\opencv_core240d.lib
C:\OpenCV2.4\lib\opencv_highgui240d.lib
C:\OpenCV2.4\lib\opencv_video240d.lib
C:\OpenCV2.4\lib\opencv_ml240d.lib
C:\OpenCV2.4\lib\opencv_legacy240d.lib
C:\OpenCV2.4\lib\opencv_imgproc240d.lib
C:\OpenCV2.4\lib\opencv_core240.lib
C:\OpenCV2.4\lib\opencv_highgui240.lib
C:\OpenCV2.4\lib\opencv_video240.lib
C:\OpenCV2.4\lib\opencv_ml240.lib
C:\OpenCV2.4\lib\opencv_legacy240.lib
C:\OpenCV2.4\lib\opencv_imgproc240.lib
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/
Extract the files into a folder ‘D:\Software\opencv’
Copy the following things to a folder in C:\OpenCV2.4
D:\Software\opencv\build\x86\vc10
D:\Software\opencv\build\include
Add the follwoing into system variable.
C:\OpenCV2.4\bin;C:\OpenCV2.4\bin\Debug;C:\OpenCV2.4\bin\Release
Create a new project and add this to your project properties:
1. Go to VC++ Directories;
2. Add 3 new Include Directories (it's the path where you installed OpenCV, include folder):
C:\OpenCV2.4\include\
C:\OpenCV2.4\include\opencv
C:\OpenCV2.4\include\opencv2
3. Add 1 new Library Directory (it's the path where you installed OpenCV, lib folder):
C:\OpenCV2.4\lib
4. Go to Linker in the left menu and select Input option
5. Add these entries on Additional Dependencies option(debug)
C:\OpenCV2.4\lib\opencv_core240d.lib
C:\OpenCV2.4\lib\opencv_highgui240d.lib
C:\OpenCV2.4\lib\opencv_video240d.lib
C:\OpenCV2.4\lib\opencv_ml240d.lib
C:\OpenCV2.4\lib\opencv_legacy240d.lib
C:\OpenCV2.4\lib\opencv_imgproc240d.lib
6. Add these entries on Additional Dependencies option(release)
C:\OpenCV2.4\lib\opencv_highgui240.lib
C:\OpenCV2.4\lib\opencv_video240.lib
C:\OpenCV2.4\lib\opencv_ml240.lib
C:\OpenCV2.4\lib\opencv_legacy240.lib
C:\OpenCV2.4\lib\opencv_imgproc240.lib
Wednesday, June 6, 2012
Team Michigen Sensor
http://april.eecs.umich.edu/magic/about/
Primary sensor is a combined camera/LIDAR rig. The camera is a PointGray FireflyMV USB camera with a 2.8mm fixed focal length lens giving us about a 90 degree field of view. The camera is mounted on a pair of AX-12 servos which allow the camera to pan and tilt around its focal point, making panorama generation straight-forward. Integrated into the same sensor mount is a Hokuyo UTM-30LX LIDAR range finder. It is mounted on a third AX-12 servo, allowing us to produce 3D point clouds. Because the two sensors are well-calibrated with respect to each other, we can obtain color data for laser points, or ranges for camera pixels. Note that the camera/LIDAR mount was fabricated using our uPrint rapid prototyper.
Primary sensor is a combined camera/LIDAR rig. The camera is a PointGray FireflyMV USB camera with a 2.8mm fixed focal length lens giving us about a 90 degree field of view. The camera is mounted on a pair of AX-12 servos which allow the camera to pan and tilt around its focal point, making panorama generation straight-forward. Integrated into the same sensor mount is a Hokuyo UTM-30LX LIDAR range finder. It is mounted on a third AX-12 servo, allowing us to produce 3D point clouds. Because the two sensors are well-calibrated with respect to each other, we can obtain color data for laser points, or ranges for camera pixels. Note that the camera/LIDAR mount was fabricated using our uPrint rapid prototyper.
Subscribe to:
Posts (Atom)