First, let's ask a question: How do you get the measurement of a rectangle in the picture below, that is, do you need more accurate rectangle position parameters? The general method provided by halcon is to first frame the rectangle, and then use the measurement object to measure accurately. Therefore, the approximate center point, length, width, and direction angle of the rectangle should be basically given, see
First, give the code, and then explain the meaning of the code one by one:
re_image (Image, 'rect2')
rgb1_to_gray(Image,Image)
create_metrology_model (MetrologyHandle)
get_image_size (Image, Width, Height)
set_metrology_model_image_size (MetrologyHandle, Width, Height)
add_metrology_object_rectangle2_measure (MetrologyHandle, 172.3, 239.2, rad(11.609), 146.7, 50.9, 30, 12, 1, 30, [], [], Index)
apply_metrology_model (Image, MetrologyHandle)
get_metrology_object_result (MetrologyHandle, Index, 'all', 'result_type', 'all_pa', Rectangle)
get_metrology_object_result_contour (Contour, MetrologyHandle, Index, 'all', 1.5)
clear_metrology_model (MetrologyHandle)
1) create_metrology_model (MetrologyHandle)
This statement defines a measurement container that can hold many different measurement objects. In this example, there is only one measurement object.
2) set_metrology_model_image_size (MetrologyHandle, Width, Height)
Define the measurement range for which the measurement container is intended, in this case the entire image.
3) add_metrology_object_rectangle2_measure( : : MetrologyHandle, Row, Column, Phi, Length1, Length2, *Define the outer containing rectangle MeasureLength1,MeasureLength2, *Define the measurement object
MeasureSigma, MeasureThreshold, GenParamName, GenParamValue: Index) *Defines the grayscale of the image being tested
To understand this statement, we must first understand the relationship between [the object to be inspected, the rectangular range box, and the object]. As shown in the following figure:
The corresponding parameters of [detected object, rectangular range frame, and detection object] are defined as follows:
* The geometry of a rectangular object is specified by its center (Row, Column), the direction of the principal axis φ, and the half-side lengths Length1 and Length2.
* Input values for Phi are automatically mapped to intervals.
* The rectangular measurement area is perpendicular to the border of the area rectangle. The half-side lengths of the measurement area perpendicular and tangent to the rectangular border are set in "Length1" and "Length2".
* The center of the measurement area lies on the border of the rectangle. The parameter MeasureSigma specifies a standard deviation that the operator uses to apply a metrological model to smooth the grayscale values of the image.
* You can select salient edges using the parameter MeasureThreshold, which constitutes an amplitude threshold, i.e. the absolute value of the first-order derivative of the edge.
Additionally, some common parameters can be adjusted in GenParamName and GenParamValue. In particular, all common parameters available in the operation set_metrology_object_param can be set. Note, however, that for many applications the default values are sufficient and no adjustments are necessary.
The operator add_metrology_object_rectangle2_measure returns the Index index of the metrology object added to the metrology model in the parameter Index.
4)get_metrology_object_result( : : MetrologyHandle, Index, Instance, GenParamName, GenParamValue : Parameter)
Get the measurement results.
get_metrology_object_result allows access to the measurement results of a measurement measurement object MetrologyHandle obtained with apply_metrology_model. The parameter Index specifies the metrology object for which the result is queried (there are multiple metrology objects in MetrologyHandle). For Index set to "all", results for all metrology objects are returned. With the parameter Instance you can specify for which measurement instance the results are returned in the parameter. Setting the instance Instance to "all" will return results for all instances. Different generic parameters can be used to control the return value in the Parameter. The generic parameter name is passed as GenParamName. The corresponding value is passed as GenParamValue. The following parameters and values are possible:
5)get_metrology_object_result_contour( : Contour : MetrologyHandle, Index, Instance, Resoluon : )
Get the measurement result, which is the contour line of the above measurement.
The final contour result is as follows:
If you still don't understand the principle, please refer to the following article, which continues to discuss this issue. You can also refer to the online article: Measurement Function
Measurement Problems
The contour line obtained above is not the measurement result. How to further solve the measurement problem? Because there are many situations, it is impossible to list them one by one. Here we only measure the rectangle mentioned in the case.
Method 1: Use fit_rectangle2_contour_xld to extract a rectangle from the contour line, based on the length and width that satisfy the measurement.
Method 2: Use gen_parallel_contour_xld(contour, parallelcontour, 'regression_normal', -Distance) to directly get the distance of parallel lines (one for length and one for width)
Reviewing Editor: Li Qian
Previous article:Analysis of the servo motor structure of industrial robots
Next article:How to connect to different configurations of frame grabbers and cameras
- Popular Resources
- Popular amplifiers
- Using IMU to enhance robot positioning: a fundamental technology for accurate navigation
- Researchers develop self-learning robot that can clean washbasins like humans
- Universal Robots launches UR AI Accelerator to inject new AI power into collaborative robots
- The first batch of national standards for embodied intelligence of humanoid robots were released: divided into 4 levels according to limb movement, upper limb operation, etc.
- New chapter in payload: Universal Robots’ new generation UR20 and UR30 have upgraded performance
- Humanoid robots drive the demand for frameless torque motors, and manufacturers are actively deploying
- MiR Launches New Fleet Management Software MiR Fleet Enterprise, Setting New Standards in Scalability and Cybersecurity for Autonomous Mobile Robots
- Nidec Drive Technology produces harmonic reducers for the first time in China, growing together with the Chinese robotics industry
- DC motor driver chip, low voltage, high current, single full-bridge driver - Ruimeng MS31211
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 5 Key Considerations for IoT Devices
- Developing Keil MDK-ARM Projects with VisualGDB
- [Sipeed LicheeRV 86 Panel Review] 5-Porting Python3 to the Development Board
- GD32F103RC burning problem
- How much processor overhead does Tracealyzer require to trace an RTOS?
- [RVB2601 Creative Application Development] Environmental Monitoring Terminal 03-Using LVGL to Design the Interface
- Weekly evaluation information delivered to you, keep up to date with new evaluation trends!
- Why does the value of the ad7747 ready register remain unchanged?
- Novice Question
- How to install tens of billions of transistors into a chip?