Mercurial > hg > nsaunier > traffic-intelligence
annotate c/test-pixels.cpp @ 398:3399bd48cb40
Ajout d'une méthode pour obtenir le nombre de FPS
Méthode de capture des trames vidéos plus résistante aux erreur
Utilisation d'un dictionnaire pour les fichier de configuration afin de garder le nom des sections
| author | Jean-Philippe Jodoin <jpjodoin@gmail.com> |
|---|---|
| date | Mon, 29 Jul 2013 13:46:07 -0400 |
| parents | eb38637f338d |
| children |
| rev | line source |
|---|---|
| 9 | 1 #include "cvutils.hpp" |
| 2 | |
|
4
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
3 #include "opencv/cv.h" |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
4 #include "opencv/highgui.h" |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
5 |
|
3
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 #include <iostream> |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 using namespace std; |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
9 |
|
4
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
10 |
|
3
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 int main(int argc, char *argv[]) { |
|
4
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
12 //cout << "Hello World" << endl; |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
13 |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
14 CvCapture *inputVideo = cvCaptureFromFile(argv[1]); |
|
3
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 |
|
4
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
16 IplImage* frame = cvQueryFrame(inputVideo); |
| 9 | 17 IplImage* bwFrame = allocateImage(frame->width, frame->height, IPL_DEPTH_8U, 1); |
|
4
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
18 |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
19 int frameNum = 0; |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
20 while (frame) { |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
21 if (frameNum%10 == 0) |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
22 cout << frameNum << endl; |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
23 cvConvertImage(frame, bwFrame); |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
24 |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
25 for (int i=0; i<frame->height; ++i) |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
26 for (int j=0; j<frame->width; ++j) |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
27 int gray = cvGetReal2D(bwFrame, i, j); |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
28 |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
29 frame = cvQueryFrame(inputVideo); |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
30 frameNum++; |
|
6509f5b1d795
updated and added makefile to compile C++ code using opencv in its directory, whipped up simple test to read the pixels in BW images
Nicolas Saunier <nico@confins.net>
parents:
3
diff
changeset
|
31 } |
|
3
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
32 |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
33 return 1; |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
34 } |
