我建立了在后台运行的程序,并检查拖曳图像是否相似。
当我在标准运行中运行时,它会很好。但是,当我想在隐藏窗口(在后台)中运行它时,出现以下错误:


  • 这是我的代码:
    #include <iostream>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <atlimage.h>
    
    using namespace cv;
    using namespace std;
    
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR     lpCmdLine, int nShowCmd) {
    
      int count_inequality = 0;
    
      Mat image, image2;
      image = imread("hh.jpg", IMREAD_COLOR); // Read thVec3b intensity =   img.at<Vec3b>(y, x);
      image2 = imread("gg.jpg", IMREAD_COLOR); // Read thVec3b intensity = img.at<Vec3b>(y, x);
      float blue;
      float green;
      float red;
      float blue2;
      float green2;
      float red2;
    
      for (int i = 1; i <= 1000; i+=10) {
          for (int h = 1; h <= 900; h += 10) {
            Vec3b intensity = image.at<Vec3b>(i, h);
            blue = intensity.val[0];
            green = intensity.val[1];
            red = intensity.val[2];
    
            Vec3b intensity2 = image2.at<Vec3b>(i, h);
            blue2 = intensity2.val[0];
            green2 = intensity2.val[1];
            red2 = intensity2.val[2];
    
            if (blue == blue2 && green == green2 && red == red2) {}
    
            else {
                  count_inequality++;
    
                  if (count_inequality == 3){
                      //Code what happens if will be 3 inequality.
                  }
              }
    
            }
        }
    return 0;
    }
    

    有人可以帮助我吗?

    最佳答案

    项目ConsoleApplication2的名称,因此我将假定您将Visual Studio项目模板用于“控制台应用程序”。

    该模板设置 \SUBSYSTEM:CONSOLE 选项,这意味着程序要从具有签名int main(int argc, char* argv[])的函数开始

    因此,您需要将该选项更改为/SUBSYSTEM:WINDOWS,或者需要更改WinMain函数的签名。

    关于c++ - 构建隐藏窗口(在后台运行)时,如何在 'opencv'函数中使用获得像素颜色的颜色?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38609780/

    10-12 16:59
    查看更多