Mercurial > hg > nsaunier > traffic-intelligence
annotate c/test-pixels.cpp @ 190:36968a63efe1
Got the connected_components to finally work using a vecS for the vertex list in the adjacency list.
In this case, the component map is simply a vector of ints (which is the type of UndirectedGraph::vextex_descriptor (=graph_traits<FeatureGraph>::vertex_descriptor) and probably UndirectedGraph::vertices_size_type).
To use listS, I was told on the Boost mailing list:
>> If you truly need listS, you will need to create a vertex index
>> map, fill it in before you create the property map, and pass it to the
>> vector_property_map constructor (and as a type argument to that class).
It may be feasible with a component map like
shared_array_property_map< graph_traits<FeatureGraph>::vertex_descriptor, property_map<FeatureGraph, vertex_index_t>::const_type > components(num_vertices(g), get(vertex_index, g));
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 07 Dec 2011 18:51:32 -0500 |
| 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 } |
