[Halcon]霍夫直线检测hough_lines


dev_close_window ()   
read_image (Image, 'D:/src.bmp')
get_image_size (Image, Width, Height)    
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)    
dev_display (Image)

rectangle1_domain(Image,ImageReduced,0, 0,Height, Width )
sobel_amp (ImageReduced, EdgeAmplitude, 'thin_sum_abs', 3)
dev_set_color('red')
threshold(EdgeAmplitude,Region,10,255)
hough_lines (Region, 2, 200, 5, 5, Angle, Dist)
dev_set_color('blue')
gen_region_hline (RegionLines,Angle, Dist)
dev_display (RegionLines)


#include "HalconCpp.h"
using namespace Halcon;

#ifndef NO_EXPORT_MAIN
// Main procedure 

void action()
{  
using namespace Halcon;// Local iconic variables 
  
Hobject  Image, ImageReduced, EdgeAmplitude, Region;
Hobject  Regions;// Local control variables 
HTuple  Angle, Dist;

  //Detect lines in an image with the help of the Hough transform
  //and return it in HNF
  //
  
read_image(&Image, "fabrik");
rectangle1_domain(Image, &ImageReduced, 230, 180, 330, 280);//Detect edges (amplitude) using the Sobel operator
sobel_amp(ImageReduced, &EdgeAmplitude, "thin_sum_abs", 3);
  
if (HDevWindowStack::IsOpen()) 
set_color(HDevWindowStack::GetActive(),"red");
threshold(EdgeAmplitude, &Region, 10, 255);
hough_lines(Region, 4, 50, 5, 5, &Angle, &Dist);
if (HDevWindowStack::IsOpen())  
set_color(HDevWindowStack::GetActive(),"blue");//Store input lines described in HNF
gen_region_hline(&Regions, Angle, Dist);
}

#ifndef NO_EXPORT_APP_MAIN


int main(int argc, char *argv[])
{
using namespace Halcon;// Default settings used in HDevelop (can be omitted) 
set_system("do_low_error","false");
action();
return 0;
}
#endif


#endif



你可能感兴趣的:([Halcon]霍夫直线检测hough_lines)