VS2019 本来好好的,莫名其妙启动程序之后卡在第一张图了

老师上课让我们写的,本来正常,图都能出来,不知怎么的点调试之后就变成图里显示的这样的,一张图都出不来,而且鼠标放在origin窗体的灰色部分时鼠标不显现,感觉被灰色部分遮挡,调试监控的调用堆栈什么都没有

img

#include <opencv2/core/core.hpp>
#include "opencv2/highgui/highgui.hpp"
#include<opencv2/imgproc/imgproc.hpp>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <strstream>
#include <stdio.h>
#include <stdlib.h>
#include "MyRoutines.h"
#include <cstdlib>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
    CvPoint TextOffsetX = { 50,60 }, TextOffsetY = { 50,30 }, SW = { 50,90 }, MW = { 50,120 }, W12 = { 50,150 }, Zeit = {50,300};
    Mat image, hist_image, tred, tgreen, tblue, tmerge,nurrot,nurblau, gray,nurgruen;
    MyRoutines Werkzeug;
    char c;
    int radius;
    Point center,zwoelf, zwoelf1,mitte, pn1, pn11, pn2, pn21;
    Moments m;
    string s;
    float kdata[] = { -1,-1,-1,
                      -1, 8,-1,
                      -1,-1,-1 };
    Mat kernel(3, 3, CV_32F, kdata);
    double sw, mw,w12;
    int Stunde, Minute;
    string minute;
    int schwelle = 60;
    vector <Mat> rgb;
    namedWindow("Origin", WINDOW_AUTOSIZE);
    image = imread("Uhr3.jpg", CV_LOAD_IMAGE_COLOR);    
    if (!image.data)                             
    {
        cout << "Could not open or find the image" << std::endl;
        return -1;
    }
        resize(image, image, Size(), 0.15, 0.15, CV_INTER_AREA);
        split(image, rgb);
        tblue = rgb[0];
        tgreen = rgb[1];
        tred = rgb[2];
        nurblau = Werkzeug.farbselect(tblue, tred, tgreen);
        nurrot = Werkzeug.farbselect(tred, tblue, tgreen);
        nurgruen = Werkzeug.farbselect(tgreen, tred, tblue);
        Werkzeug.findzwoelf(nurgruen, &zwoelf);
        Werkzeug.findcenter(nurblau, &center, &radius);
        circle(image, center, 10, CV_RGB(255, 0, 255), CV_FILLED, LINE_AA);
        circle(image, center, radius, Scalar(255, 0, 255), 3, LINE_AA);
        s = "x=" + to_string(center.x) + ",y=" + to_string(center.y);
        putText(image, s, center, FONT_HERSHEY_COMPLEX, 1, CV_RGB(255, 0, 0));
        putText(image, "radius=" + to_string(radius), TextOffsetX, FONT_HERSHEY_COMPLEX, 1, CV_RGB(255, 0, 0));
        circle(image, zwoelf, 10, CV_RGB(255, 0, 255), CV_FILLED, LINE_AA);
        putText(image, "Shen Kaihan", TextOffsetY, FONT_HERSHEY_COMPLEX, 1, CV_RGB(255, 255, 255));
        nurblau = Werkzeug.maskclock(nurblau, schwelle);
        bitwise_and(nurrot, nurblau, nurrot);
        erode(nurrot, nurrot, Mat(), Point(-1, -1), 3);
        threshold(nurrot, nurrot, 50, 255, THRESH_BINARY);
        Werkzeug.findezeiger(nurrot, center, radius, &pn2, &pn1);
        circle(image, pn1, 5, CV_RGB(199, 0, 106), CV_FILLED, LINE_AA);
        circle(image, pn2, 5, CV_RGB(199, 0, 106), CV_FILLED, LINE_AA);
        Werkzeug.Uhrzeit(center, zwoelf, pn1, pn2, &Stunde, &Minute);
        if (Minute < 10) {minute = "0" + to_string(Minute);        }
        else        {            minute = to_string(Minute);        }
        putText(image, to_string(Stunde)+":"+minute, Zeit, FONT_HERSHEY_COMPLEX, 1, CV_RGB(0, 0, 0));
        filter2D(image, tmerge, -1, kernel);
        c = waitKey(0);                                        
        if (c == 's') {            imwrite("Shen_Kaihan.jpg", image);        }
        imshow("Origin", image);
        imshow("Gefiltet", tmerge);
        imshow("nurgruen", nurgruen);
        return 0;
        destroyWindow("Origin");
        destroyWindow("Gefiltet");
        destroyWindow("nurgruen");

}


//Werkzeug
void MyRoutines::CalculateHist(Mat image) {
    int histSize = 256;
    Mat dst, hist,red,blue,green;
    namedWindow("histogram", 0);
    image.convertTo(dst, CV_8U);
    calcHist(&dst, 1, 0, Mat(), hist, 1, &histSize, 0);
    Mat histImage = Mat::ones(250, 512, CV_8U) * 255;
    normalize(hist, hist, 0, histImage.rows, CV_MINMAX, CV_32F);
    histImage = Scalar::all(255);
    int binW = cvRound((double)histImage.cols / histSize);
    for (int i = 0; i < histSize; i++)
        rectangle(histImage, Point(i*binW, histImage.rows),
            Point((i + 1)*binW, histImage.rows - cvRound(hist.at<float>(i))),
            Scalar::all(0), -1, 8, 0);
    imshow("histogram", histImage);
}

int MyRoutines::getkey() {
    return (cvWaitKey(1));
}

Mat MyRoutines::farbselect(Mat farbe1, Mat farbe2, Mat farbe3) {
    return (2*farbe1-farbe2-farbe3);
}

Mat MyRoutines::maskclock(Mat inpic, int schwelle) {
    Mat bild=inpic;
    threshold(bild, bild, schwelle, 255, THRESH_BINARY);
    erode(bild, bild, Mat(), Point(-1, -1), 3);
    dilate(bild, bild, Mat(), Point(-1, -1), 3);
    dilate(bild, bild, Mat(), Point(-1, -1), 12);
    erode(bild, bild, Mat(), Point(-1, -1), 12);
    return bild;
}

Mat MyRoutines::findcenter(Mat inpic, Point* Center, int* radius) {
    Mat image = inpic;
    GaussianBlur(image, image, Size(9, 9), 2, 2);
    vector<Vec3f> circles;
    HoughCircles(image, circles, HOUGH_GRADIENT, 1, image.rows / 10, 100, 30, 1, image.cols / 2);
    
    for (size_t i = 0; i < circles.size(); i++)
    {
        Vec3i c = circles[i];
        Point center = Point(c[0], c[1]);
        circle(image, center, 1, Scalar(0, 100, 100), 3, LINE_AA);
        int radius1 = c[2];
        circle(image, center, radius1, Scalar(255, 0, 255), 3, LINE_AA);
        *Center = center;
        *radius = radius1;
    }
    return image;
}

void MyRoutines::findzwoelf(Mat inpic, Point* Center) {
    Moments m; Point center;
    threshold(inpic, inpic, 50, 255, THRESH_BINARY);
    m = moments(inpic);
    center.x = m.m10 / m.m00;
    center.y = m.m01 / m.m00;
    *Center = center;
}

void MyRoutines::findezeiger(Mat bild, Point Center,int radius, Point* kz, Point* gz) {
    Point pn1, pn2;
    int m=0;

    unsigned char color;
    for (int n = 0; n <= 360; n += 5) {
        pn1.x = Center.x - 0.8 * radius * cos(n * M_PI / 180);
        pn1.y = Center.y - 0.8 * radius * sin(n * M_PI / 180);
        color = bild.at<unsigned char>(pn1);
        if (color) {
            *gz = pn1;
            m = n;
            break;
        }
    }
    bool flag=true;
    for (int n = 0; n <= 360; n += 5) {
        pn2.x = Center.x - 0.3 * radius * cos(n * M_PI / 180);
        pn2.y = Center.y - 0.3 * radius * sin(n * M_PI / 180);
        color = bild.at<unsigned char>(pn2);
        if (color) {
            if ((pn1.x - Center.x) * (pn2.y - Center.y) - (pn2.x - Center.x) * (pn1.y - Center.y) != 0 ) {
                 *kz = pn2;
                 flag = false;
                 break;
            }
            if ((pn1.x - Center.x) * (pn2.y - Center.y) - (pn2.x - Center.x) * (pn1.y - Center.y) == 0 && (pn1.x - Center.x) * (pn2.x - Center.x) < 0)
            {
                *kz = pn2;
                flag = false;
                break;
            }
        }
    }
    if (flag==true)
    {
        pn2.x = Center.x - 0.3 * radius * cos(m * M_PI / 180);
        pn2.y = Center.y - 0.3 * radius * sin(m * M_PI / 180);
        *kz = pn2;
    }
}
void MyRoutines::Uhrzeit(Point Center, Point zwoelf, Point kz, Point gz, int* Stunde, int* Minute) {
    int   w, sw, mw, s, m;
    Point pn1, pn2, zwoelf1;
    zwoelf1 = zwoelf - Center;
    pn2 = gz - Center;
    pn1 = kz - Center;
    w = atan2((double)zwoelf1.y, (double)zwoelf1.x) * 180 / M_PI;
    sw = atan2((double)pn2.y, (double)pn2.x) * 180 / M_PI;

    mw = atan2((double)pn1.y, (double)pn1.x) * 180 / M_PI;

    sw = sw - w;
    mw = mw - w;
    if (sw < 0) {
        sw = 360 + sw;
    }
    if (mw < 0) {
        mw = 360 + mw;
    }
    s = sw / 30;
    m = mw / 6;
    *Stunde = s;
    *Minute = m;
}
这是监控输出

“Uhr1.exe”(Win32): 已加载“C:\Users\苟\source\repos\Uhr1\x64\Debug\Uhr1.exe”。已加载符号。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\ntdll.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\kernel32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\KernelBase.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\opencv_world320d.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\user32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\win32u.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\gdi32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\gdi32full.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\msvcp_win.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\ucrtbase.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\ole32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\rpcrt4.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\combase.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\oleaut32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\comdlg32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\msvcrt.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\SHCore.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\shlwapi.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\shell32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\advapi32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\sechost.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\msvcp140d.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\vcruntime140d.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\vcruntime140_1d.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\ucrtbased.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.19041.1110_none_792d1c772443f647\comctl32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\msvfw32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\avifil32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\avicap32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\concrt140d.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\winmm.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\msacm32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\winmmbase.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\imm32.dll”。

***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****

线程 0x3480 已退出,返回值为 0 (0x0)。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\uxtheme.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\msctf.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\kernel.appcore.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\bcryptprimitives.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\TextInputFramework.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\CoreMessaging.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\CoreUIComponents.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\ws2_32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\ntmarta.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\WinTypes.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\WinTypes.dll”。
“Uhr1.exe”(Win32): 已卸载“C:\Windows\System32\WinTypes.dll”
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\OpenCL.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\cfgmgr32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\clbcatq.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\AppXDeploymentClient.dll”。
“Uhr1.exe”(Win32): 已卸载“C:\Windows\System32\AppXDeploymentClient.dll”
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\dxgi.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\ResourcePolicyClient.dll”。
“Uhr1.exe”(Win32): 已卸载“C:\Windows\System32\ResourcePolicyClient.dll”
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_afa18c61a36f2728\igdrcl64.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\DXCore.dll”。
“Uhr1.exe”(Win32): 已卸载“C:\Windows\System32\DXCore.dll”
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_afa18c61a36f2728\igdgmm64.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\DXCore.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\opengl32.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\glu32.dll”。
“Uhr1.exe”(Win32): 已卸载“C:\Windows\System32\glu32.dll”
“Uhr1.exe”(Win32): 已卸载“C:\Windows\System32\opengl32.dll”
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_afa18c61a36f2728\igdfcl64.dll”。
“Uhr1.exe”(Win32): 已加载“C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_afa18c61a36f2728\igc64.dll”。
线程 0x366c 已退出,返回值为 0 (0x0)。
线程 0x5b0 已退出,返回值为 0 (0x0)。
线程 0x2030 已退出,返回值为 0 (0x0)。

我的解答思路和尝试过的方法
我想要达到的结果