Halcon Camera Calibration

Source: Internet
Author: User

Halcon Program

* Internal parameters of the camera:
*f: The camera's main moment, the focal length
*k: Radial distortion, that is, radial distortions, generally do not consider tangential distortion
*sx,sy: distance between adjacent pixels in the horizontal and vertical direction of the image sensor
*cx,cy: Vertical projection of the projection center in the imaging plane

* External camera parameters
* translation vector x, y, Z
* Rotation vector x, y, Z

* Perspective correction

Dev_close_window ()
Dev_update_off ()
Dev_set_draw (' margin ')
Read_image (image, ' scratch/scratch_perspective ')
Get_image_size (image, Width, Height)
Dev_open_window (0, 0, Width, Height, ' black ', windowhandle)
Set_display_font (WindowHandle, +, ' mono ', ' true ', ' false ')
Dev_display (Image)
Disp_continue_message (WindowHandle, ' black ', ' true ')

* Calibration Camera

* Calibration Board Description file
Caltabname: = ' CALTAB_30MM.DESCR '

* Initial Internal parameters
* Parameters: Focal length, thickness, width of single cell, height of single cell, graphics center x, image Center Y, graphics width, image height
Startcampar: = [0.012,0,0.0000055,0.0000055, WIDTH/2, HEIGHT/2, Width, Height]

* Create a calibration data model
Create_calib_data (' Calibration_object ', 1, 1, Calibdataid)

* Set Calibration camera parameter model
Set_calib_data_cam_param (calibdataid, 0, ' area_scan_division ', Startcampar)

* Define the calibration board description file in the calibration model
Set_calib_data_calib_object (calibdataid, 0, Caltabname)

***********************************
* Obtain the center coordinates of the mark points in the calibration board description file
* Caltab_points (Caltabname,x, Y, Z)
* Nstartpose: = []
* Nrow: = []
* Ncol: = []
***********************************

Numimages: =
For I: =1 to Numimages by 1
read_image (image, ' scratch/scratch_calib_ ' +i$ ' 02d ')
Dev_display (Image)
* Find Calibration Board area
Find_caltab (Image, Caltab, Caltabname, 3, 5)
Dev_set_color (' green ')
Dev_display (Caltab) br>
* Look for the calibration plate marker point coordinates and estimated external parameters
Find_marks_and_pose (Image, Caltab, Caltabname, startcampar,128, ten, X, 0.9, +, +, Rcoord , Ccoord, Startpose)
Dev_set_color (' red ')
Disp_circle (WindowHandle, Rcoord, Ccoord, Gen_tuple_const (| rcoord|,2.5))
Dev_set_part (0, 0, Height-1, Width-1)

* Store calibration information to the calibration board model
Set_calib_data_observ_points ( Calibdataid, 0, 0, I, Rcoord, Ccoord, ' all ', startpose)

******************************
* Combine all calibrated external and central coordinates
* Nstartpose: = [Nstartpose, Startpose]
* nrow: = [Nrow, Rcoord]
* Ncol: = [Ncol, Ccoord]
************************
ENDfor

******************************
* Calibration of all camera parameters (can not use operator set_calib_data_observ_points)
* Camera_calibration (X, Y, Z, Nrow, Ncol, Startcampar, Nstartpose, ' All ', Cameraparam, Nfinalpose, Errors)
******************************

* Calibration Camera parameters
Calibrate_cameras (Calibdataid, Error)

* Get in-camera parameters
Get_calib_data (Calibdataid, ' camera ', 0, ' params ', camparam)

* Get External camera parameters
Get_calib_data (Calibdataid, ' calib_obj_pose ', [0,1], ' pose ', posecalib)


* Convert Origin coordinates
Set_origin_pose (Startpose, -0.04, -0.03, 0.00075, pose)

* Set the calibrated image a pixel represents the actual distance
Pixeldist: = 0.00013

* Image Image generation
Gen_image_to_world_plane_map (map, Camparam, Pose, width, height, width, height, pixeldist, ' bilinear ')

Imagefiles: = [' scratch/scratch_calib_01 ', ' scratch/scratch_perspective ']
For i:= 1 to 2 by 1
Read_image (image, Imagefiles[i-1])
Dev_set_window (WindowHandle)
Dev_display (Image)


* Apply image to convert image
Map_image (image, map,imagemapped)

ENDfor

Camera_parameters.dat File Contents

#
# INTERNAL CAMERA PARAMETERS
#

# ===== generic parameter Syntax ==========================================
#
# Syntax:pargroup: <pargroupname>;
# <pargroup_description>;
#
# <name>: <shortname>: <default_value>;
# <type>: <lower_bound>: <upper_bound>;
# <description>;
#
# [<type>:: = bool| Xbool|int| Float| double| STRING]
#
# =========================================================================

##############################################################################
#
# Camera:parameter
# > Focus
# > Kappa
# > Sx
# > Sy
# > Cx
# > Cy
# > ImageWidth
# > ImageHeight
#
##############################################################################

ParGroup:Camera:Parameter;
"Internal camera Parameters";

focus:foc:0.0161703501831527;
double:0.0:;
"Focal length of the lens";

kappa:kappa:-639.990421851654;
DOUBLE::;
"Radial distortion coefficient";

sx:sx:7.40108791846177e-006;
double:0.0:;
"Width of a cell on the sensor";

sy:sy:7.4e-006;
double:0.0:;
"Height of a cell on the sensor";

cx:cx:333.895895987285;
DOUBLE::;
"X-coordinate of the Image Center";

cy:cy:244.935973115852;
DOUBLE::;
"Y-coordinate of the Image Center";

imagewidth:imgw:652;
int:1:32768;
"Width of the images";

imageheight:imgh:494;
int:1:32768;
"Height of the images";


#
# HALCON Version 12.0--Tue APR 14 22:41:15 2015
#

Camera_pose.dat File Contents

#
# 3D POSE parameters:rotation and translation
#

# Used representation Type:
F 0

# Rotation angles [deg] or Rodriguez vector:
R 3.11886998639614 358.984666972156 30.2659614074603

# translation vector (x y Z [m]):
T 0.0248668618545196 0.0133955230862179 0.401474091384729

#
# HALCON Version 12.0--Tue APR 14 22:41:15 2015

#

Halcon Camera Calibration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.