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
在Visual Studio 2015中运行Opencv示例时出现应用程序错误(0xc000007b)_Opencv_Visual Studio 2015 - Fatal编程技术网

在Visual Studio 2015中运行Opencv示例时出现应用程序错误(0xc000007b)

在Visual Studio 2015中运行Opencv示例时出现应用程序错误(0xc000007b),opencv,visual-studio-2015,Opencv,Visual Studio 2015,我正在Visual Studio 2015中运行canny edge示例,但我遇到了此错误 应用程序无法正确启动(0xc000007b) 然后VisualStudio显示此错误 Canny Edge.exe中0x77A2D5B2(ntdll.dll)处未处理的异常:0xC000007B:%hs不是设计用于在Windows上运行的,或者它包含错误。请尝试使用原始安装介质再次安装程序,或与系统管理员或软件供应商联系以获得支持。错误状态0x 我非常确定这个编码是有效的,因为我以前在VisualStud

我正在Visual Studio 2015中运行canny edge示例,但我遇到了此错误

应用程序无法正确启动(0xc000007b)

然后VisualStudio显示此错误

Canny Edge.exe中0x77A2D5B2(ntdll.dll)处未处理的异常:0xC000007B:%hs不是设计用于在Windows上运行的,或者它包含错误。请尝试使用原始安装介质再次安装程序,或与系统管理员或软件供应商联系以获得支持。错误状态0x

我非常确定这个编码是有效的,因为我以前在VisualStudio2013中运行过这个编码。这是我的代码

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>
#include <algorithm>

using namespace cv;
using namespace std;

void help()
{
    cout << "\nThis program demonstrates line finding with the Hough transform.\n"
        "Usage:\n"
        "./houghlines <image_name>, Default is pic1.jpg\n" << endl;
}

bool less_by_y(const cv::Point& lhs, const cv::Point& rhs)
{
    return lhs.y < rhs.y;
}

int main(int argc, char** argv)
{
    const char* filename = argc >= 2 ? argv[1] : "pic1.jpg";

    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;
    Rect roi;

    Mat src = imread("test_4_1.png");
    if (src.empty())
    {
        help();
        cout << "can not open " << filename << endl;
        return -1;
    }

    Mat dst, cdst;
    Canny(src, dst, 50, 200, 3);
    cvtColor(dst, cdst, CV_GRAY2BGR);
    findContours(dst, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));

    //vector<Vec2f> lines;
    //HoughLines(dst, lines, 1, CV_PI / 180, 50, 0, 0);

    //for (size_t i = 0; i < lines.size(); i++)
    //{
    //  float rho = lines[i][0], theta = lines[i][1];
    //  Point pt1, pt2;
    //  double a = cos(theta), b = sin(theta);
    //  double x0 = a*rho, y0 = b*rho;
    //  pt1.x = cvRound(x0 + 1000 * (-b));
    //  pt1.y = cvRound(y0 + 1000 * (a));
    //  pt2.x = cvRound(x0 - 1000 * (-b));
    //  pt2.y = cvRound(y0 - 1000 * (a));
    //  line(cdst, pt1, pt2, Scalar(0, 0, 255), 1, CV_AA);
    //  cout << pt1 << "    " << pt2 << endl;
    //}

    vector<Vec4i> lines;
    HoughLinesP(dst, lines, 1, CV_PI / 180, 30, 50, 10);
    for (size_t i = 0; i < lines.size(); i++)
    {
        Vec4i l = lines[i];
        line(cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 1, CV_AA);
        cout << l << endl;
    }

    cout << endl << lines.size() << endl;
    cout << arcLength(contours[0], true) << endl;
    cout << dst.size() << endl << endl;

    for (int a = 0; a < contours[0].size(); a++){
        cout << contours[0][a] << " ";
    }

    vector<Point> test = contours[0];
    auto mmx = std::minmax_element(test.begin(), test.end(), less_by_y);
    cout << endl << *mmx.first._Ptr << endl << *mmx.second._Ptr;

    vector<Point> test2 = contours[1];
    auto mmx_1 = std::minmax_element(test2.begin(), test2.end(), less_by_y);
    cout << endl << *mmx_1.first._Ptr << endl << *mmx_1.second._Ptr;

    imshow("source", src);
    imshow("detected lines", cdst);

    /* ROI by creating mask for the parallelogram */
    Mat mask = cvCreateMat(dst.size().height, dst.size().width, CV_8UC1);
    // Create black image with the same size as the original
    for (int i = 0; i < mask.cols; i++)
        for (int j = 0; j < mask.rows; j++)
            mask.at<uchar>(Point(i, j)) = 0;

    cout <<endl<<endl<< *mmx.first._Ptr << *mmx.second._Ptr << *mmx_1.first._Ptr << *mmx_1.second._Ptr << endl;

    // Create Polygon from vertices
    vector<Point> ROI_Vertices = { *mmx.first._Ptr, *mmx.second._Ptr, *mmx_1.first._Ptr, *mmx_1.second._Ptr};

    vector<Point> ROI_Poly;
    approxPolyDP(ROI_Vertices, ROI_Poly, 1.0, false);

    // Fill polygon white
    fillConvexPoly(mask, &ROI_Poly[0], ROI_Poly.size(), 255, 8, 0);
    cout << ROI_Poly.size() << endl;

    // Create new image for result storage
    Mat imageDest = cvCreateMat(dst.size().height, dst.size().width, CV_8UC3);

    // Cut out ROI and store it in imageDest
    src.copyTo(imageDest, mask);

    imshow("mask", mask);
    imshow("image", imageDest);

    waitKey();

    return 0;
}
#包括“opencv2/highgui/highgui.hpp”
#包括“opencv2/imgproc/imgproc.hpp”
#包括
#包括
使用名称空间cv;
使用名称空间std;
无效帮助()
{

cout实际上我的评论就是答案,还有一些补充


你链接到什么OpenCV库?你链接到vs12吗?因为 对于MSVS 2015,您需要将链接器升级到vs13

OpenCV不附带Visual Studio 15预构建,因此您需要自己为VS2015构建OpenCV


似乎也遇到了类似的问题,并向您介绍了如何为VS2015编译。事实上,我的评论就是答案,还有一些补充


你链接到什么OpenCV库?你链接到vs12吗?因为 对于MSVS 2015,您需要将链接器升级到vs13

OpenCV不附带Visual Studio 15预构建,因此您需要自己为VS2015构建OpenCV


似乎也遇到了类似的问题,并向您介绍了如何为VS2015编译

您链接到的OpenCV库是什么?您链接到的是vs12吗?因为您需要为MSVS2015将链接器升级到vs13吗?您链接到的是什么OpenCV库?您链接到的是vs12吗?因为您需要为MSVS2015将链接器升级到vs13谢谢您非常感谢!非常感谢!