annotate c/test-pixels.cpp @ 1262:f10e84505443

modif for highway level of service
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 17 Apr 2024 16:46:23 -0400
parents eb38637f338d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
eb38637f338d created cvutils
Nicolas Saunier <nico@confins.net>
parents: 8
diff changeset
1 #include "cvutils.hpp"
eb38637f338d created cvutils
Nicolas Saunier <nico@confins.net>
parents: 8
diff changeset
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
eb38637f338d created cvutils
Nicolas Saunier <nico@confins.net>
parents: 8
diff changeset
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 }