Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 从低质量图像解码二维码(使用ZBar)_Opencv_Qr Code_Zbar - Fatal编程技术网

Opencv 从低质量图像解码二维码(使用ZBar)

Opencv 从低质量图像解码二维码(使用ZBar),opencv,qr-code,zbar,Opencv,Qr Code,Zbar,我尝试从如下图像中解码二维码: 根据, #包括 #包括 #包括 #包括 使用名称空间cv; 使用名称空间std; 使用名称空间zbar; //g++main.cpp/usr/local/include//usr/local/lib/-lopencv_highgui.2.4.8-lopencv_core.2.4.8 int main(int argc,char*argv[]) { VideoCapture(0);//打开0号摄像机 //封盖套件(CV、封盖、道具、框架、宽度,800); //封盖

我尝试从如下图像中解码二维码:

根据,

#包括
#包括
#包括
#包括
使用名称空间cv;
使用名称空间std;
使用名称空间zbar;
//g++main.cpp/usr/local/include//usr/local/lib/-lopencv_highgui.2.4.8-lopencv_core.2.4.8
int main(int argc,char*argv[])
{
VideoCapture(0);//打开0号摄像机
//封盖套件(CV、封盖、道具、框架、宽度,800);
//封盖套件(CV、封盖、支架、高度640);
如果(!cap.isopend())//如果不成功,退出程序
{

cout什么/哪里有错误?没有错误,它只是检测不到任何符号。(它找不到任何二维码)
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <zbar.h>
#include <iostream>

using namespace cv;
using namespace std;
using namespace zbar;

//g++ main.cpp /usr/local/include/ /usr/local/lib/ -lopencv_highgui.2.4.8 -lopencv_core.2.4.8

int main(int argc, char* argv[])
{
    VideoCapture cap(0); // open the video camera no. 0

   // cap.set(CV_CAP_PROP_FRAME_WIDTH,800);
   // cap.set(CV_CAP_PROP_FRAME_HEIGHT,640);

    if (!cap.isOpened())  // if not success, exit program
    {
        cout << "Cannot open the video cam" << endl;
        return -1;
    }


    ImageScanner scanner;  
      scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);  

   double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
   double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

    cout << "Frame size : " << dWidth << " x " << dHeight << endl;

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

    while (1)
    {
        Mat frame;

        bool bSuccess = cap.read(frame); // read a new frame from video

         if (!bSuccess) //if not success, break loop
        {
             cout << "Cannot read a frame from video stream" << endl;
             break;
        }

        Mat grey;
        cvtColor(frame,grey,CV_BGR2GRAY);

        int width = frame.cols;  
        int height = frame.rows;  
        uchar *raw = (uchar *)grey.data;  
        // wrap image data  
        Image image(width, height, "Y800", raw, width * height);  
        // scan the image for barcodes  
        int n = scanner.scan(image);  
        // extract results  
        for(Image::SymbolIterator symbol = image.symbol_begin();  
        symbol != image.symbol_end();  
        ++symbol) {  
                vector<Point> vp;  
        // do something useful with results  
        cout << "decoded " << symbol->get_type_name()  << " symbol \"" << symbol->get_data() << '"' <<" "<< endl;  
           int n = symbol->get_location_size();  
           for(int i=0;i<n;i++){  
                vp.push_back(Point(symbol->get_location_x(i),symbol->get_location_y(i))); 
           }  
           RotatedRect r = minAreaRect(vp);  
           Point2f pts[4];  
           r.points(pts);  
           for(int i=0;i<4;i++){  
                line(frame,pts[i],pts[(i+1)%4],Scalar(255,0,0),3);  
           }  
           //cout<<"Angle: "<<r.angle<<endl;  
        }  

        imshow("MyVideo", frame); //show the frame in "MyVideo" window

        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
       {
            cout << "esc key is pressed by user" << endl;
            break; 
       }
    }
    return 0;

}