Digital optics revolution has reached a point where you can buy cheap digital webcamera ranged from less than 9 euros. In rupiah it should be less than 100.000 Rupiahs. Anyway this webcamera is the most important part in the image processing with opencv which is covered in this blog. Make sure you don't buy a cheap one. Cheap buy is expensive buy. Make sure you buy a fine one, a bit pricey is not a big deal as long as it has good capabilities. In your laptop probably you have also an integrated webcamera. Mostly it sucks. So make sure you have a decent one. I personally am using a cheap webcam from Genius. It was around 100.000 rupiah when I bought it. But it is way much better than my laptop webcam. My webcam is not the best webcam available out there. But it is good enough (for begineer projects especially).
picture 0_my_webcam |
Connect your webcam to your computer and make sure everything is properly installed. To use a webcamera in opencv, you need an interface called CvCapture. From the CvCapture interface, you can generate a webcamera image frame with cvQueryFrame.
#include <cv.h> #include <highgui.h> int main( int argc, char **argv ) { CvCapture* capture = cvCaptureFromCAM(0); // check if the interface to the webcam is okay. if(!capture) { fprintf(stderr, "Cannot open initialize webcam!\n" ); return 1; } // create a window for the image from the webcam cvNamedWindow("result", CV_WINDOW_AUTOSIZE); IplImage* frame; while(cvWaitKey(1) != 'q') { frame = cvQueryFrame(capture); if(frame) { cvShowImage("result", frame); } else { break; } } // free memory cvDestroyWindow("result"); cvReleaseCapture(&capture); return 0; }
Then, just show the frame continously in the window. This is the main principle of using your webcamera in opencv. Not such a long tutorial though because ...well... it is very simple. Questions are welcome. Just add it in the post and we will answer it.
picture 1_the_result |
2 comments:
mas,, kira-kira hasil gambar dari serial camera bisa diolah di opencv tidak ? contohnya serial kamera pada link ini http://www.sparkfun.com/products/10061 ,, Nanti data imagenya kan bisa dibaca dari serial port,, nah pertanyaannya apakah memungkinkan datanya itu diolah oleh opencv ?
hmmm...
maksudnya anda, data imagenya yang keluar dari serial port RS232 ke komputer, Apakah bisa diinterface/baca menggunakan OpenCV ?
Wah kalo itu saya gak tau mas, belom pernah main pake kamera TTL. tapi seharusx kalo kamerax udah bisa terhubung ke komputer sebelumnya.. pasti bisa dideteksi oleh opencv.
kalo kulihat dari datasheetx ma flowchartx harusnya pasti bisa.
Post a Comment