Opencvバーコード(2)画像の読み込みと表示

5569 ワード

Opencvの中国語のウェブサイトの簡単な過程を見て、多くのコードはopencv 1です.0バージョンとか、C言語とか、書くのが分かりにくい感じがします.
简単な机能を実现すれば、まずそんなに多くのコードを考えずに少なくすればいいと思いますので、ここに私のコードを贴り付けます.
環境:win 7(64ビット)+opencv 2.4.3+Qt 5.0.1(mingw 47_32)
qtのProファイルに追加:
INCLUDEPATH+=C:/software/opencv/buildForMinGW/install/include\
C:/software/opencv/buildForMinGW/install/include/opencv\
C:/software/opencv/buildForMinGW/install/include/opencv2
 
 
LIBS+=C:/software/opencv/buildForMinGW/install/lib/libopencv_calib3d243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_contrib243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_core243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_features2d243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_flann243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_gpu243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_highgui243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_imgproc243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_legacy243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_ml243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_nonfree243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_objdetect243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_photo243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_stitching243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_ts243.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_video243.dll.a\
C:/software/opencv/buildForMinGW/install/lib/libopencv_videostab243.dll.a



:

 1 /*
 2  *environment:opencv2.4.3+Qt5.0.1(mingw47)
 3  *author:ChrisZZ
 4  *  :          
 5  *        namedWindow   
 6  */
 7 #include <cv.h>
 8 #include <highgui.h>
 9 
10 using namespace cv; //     cv           
11 
12 int main(){
13     Mat img = imread("C:/testdir/barcode.bmp"); //  Mat       
14 
15     if(!img.data) //          
16          return -1; //         
17     //    ,              
18     namedWindow("myImgWindow", CV_WINDOW_AUTOSIZE);
19 
20     //    。            ,          。  imshow        
21     imshow("loveLena", img);
22 
23     waitKey(); //    
24 
25     return 0;
26 }

私はバーコードを作っているので、ここの写真はbarcodeと呼ばれています.bmp