main.cpp

Jochen Goertler, 2015-02-20 05:48 pm

Download (938 Bytes)

 
1
#include <iostream>
2
3
#include <opencv2/core/core.hpp>
4
#include <opencv2/highgui.hpp>
5
6
using namespace std;
7
using namespace cv;
8
9
typedef cv::Mat_<cv::Vec3b> Image;
10
11
struct Segmentation
12
{
13
    Image img;
14
};
15
16
struct Segmentation2
17
{
18
    Segmentation2( const Image & img ) : _img( img ) {}
19
    Image image() { return _img; }
20
private:
21
    Image _img;
22
};
23
24
int main( int argc, char ** argv )
25
{
26
    Image img = imread( argv[1] );
27
28
    Segmentation  s1 {img};
29
    Segmentation2 s2( img );
30
31
    cout << "This will work." << endl;
32
    for ( auto lit = s1.img.begin() ; lit != s1.img.end(); lit++ ) {}
33
34
    cout << "This will work as well." << endl;
35
    for ( auto i : s2.image() ) {}
36
37
    cout << "This will not work!" << endl;
38
    for ( auto lit2 = s2.image().begin(); lit2 != s2.image().end(); lit2++ ) {}
39
40
    cout << "This will not work!" << endl;
41
    for ( auto lit3 = begin( s2.image() ); lit3 != end( s2.image() ); lit3++ ) {}
42
43
    return 0;
44
}