zoukankan      html  css  js  c++  java
  • VC/halcon入门之显示图片

    建立vc++控制台程序

    添加代码如下:

    #include "stdafx.h"
    
    
    #include "HalconCpp.h"
    #include <iostream>
    using namespace Halcon;
    using namespace std;
    int main(int argc, char *argv[])
    {
      cout << "-------------------------------" << endl;
      cout << "Example program for HALCON/C++:" << endl;
      cout << "-------------------------------" << endl;
      cout << "- read image <monkey>" << endl;
      cout << "- open graphics window" << endl;
      cout << "- segmentation of the eyes" << endl << endl;
    
    
      HRegionArray  Eyes;                     // result of the segmentation
      HByteImage    Mandrill("monkey");       // read input image
      HWindow       w(0,0,Mandrill.Width(),Mandrill.Height());   // open window
    
      w.SetPart(0,0,Mandrill.Height()-1,Mandrill.Width()-1);
    
      Mandrill.Display (w);                   // display the Mandrill
    
      HRegionArray regs = (Mandrill >= 128).Connection();  // find bright regions
    
      for (long i = 0; i < regs.Num(); i++)   // check each region
      {
        if ((regs[i].Area() > 500) &&         // for minimum size
            (regs[i].Area() < 50000) &&       // for maximum size
        (regs[i].Anisometry() < 1.7))     // and shape
        {
           Eyes.Append(regs[i]);              // add found region to the list
        }
      }
    
      w.SetColor("red");                      // prepare display of regions
      w.SetDraw("margin");
      w.SetLineWidth(3);
    
      (Eyes.FillUp() << 9).Display(w);        // expand filled eyes and display
      w.Click();                              // wait for mouse click
    
      cout << "The End." << endl;
      return(0);
    }

    运行结果如下:

    通过该例程,我们可以得出在vc中使用Halcon时,通过Halcon提供的类函数处理数据,遵循c++的语法知识。

  • 相关阅读:
    Java 处理cookie的方法
    HTML5的新标签-整体布局
    Git学习文档——文件状态git status
    Css中路径data用法
    python2
    hangfire
    Nginx系列~Nginx服务启动不了
    git形成本地仓库并从远处url拉取
    orcal和sql server中的字符串查找函数
    Eclipse 修改项目名称
  • 原文地址:https://www.cnblogs.com/wt1990/p/4505433.html
Copyright © 2011-2022 走看看