VC/halcon入門之顯示圖片

創建vc++控制檯程序ios

添加代碼以下:c++

#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++的語法知識。spa

相關文章
相關標籤/搜索