CN114003978A - Workpiece template generation method and device and electronic equipment - Google Patents
Workpiece template generation method and device and electronic equipment Download PDFInfo
- Publication number
- CN114003978A CN114003978A CN202111302266.8A CN202111302266A CN114003978A CN 114003978 A CN114003978 A CN 114003978A CN 202111302266 A CN202111302266 A CN 202111302266A CN 114003978 A CN114003978 A CN 114003978A
- Authority
- CN
- China
- Prior art keywords
- template
- target workpiece
- workpiece
- image
- cluster
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 68
- 230000009466 transformation Effects 0.000 claims description 43
- PXFBZOLANLWPMH-UHFFFAOYSA-N 16-Epiaffinine Natural products C1C(C2=CC=CC=C2N2)=C2C(=O)CC2C(=CC)CN(C)C1C2CO PXFBZOLANLWPMH-UHFFFAOYSA-N 0.000 claims description 33
- 238000010586 diagram Methods 0.000 claims description 10
- 238000010276 construction Methods 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 6
- 239000003086 colorant Substances 0.000 claims description 4
- 238000004519 manufacturing process Methods 0.000 description 7
- 238000003860 storage Methods 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 238000007796 conventional method Methods 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 239000000463 material Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000009977 dual effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/10—Geometric CAD
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/02—Affine transformations
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
- G06T2207/30164—Workpiece; Machine component
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Geometry (AREA)
- Pure & Applied Mathematics (AREA)
- Mathematical Optimization (AREA)
- Mathematical Analysis (AREA)
- Computer Hardware Design (AREA)
- Evolutionary Computation (AREA)
- General Engineering & Computer Science (AREA)
- Computational Mathematics (AREA)
- Image Analysis (AREA)
Abstract
The invention provides a method and a device for generating a workpiece template and electronic equipment, wherein the method comprises the following steps: constructing a background image of a target workpiece; constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image; judging the geometric characteristics of the target workpiece; determining the angle range of the template cluster according to the geometric characteristics of the target workpiece; and generating the template cluster of the corresponding type through the template image according to the angle range of the template cluster. According to the workpiece template generation method, the workpiece template generation device and the electronic equipment, the angle range of the template cluster is determined through the geometric characteristics of the target workpiece, so that the template cluster of the corresponding type is generated, the template cluster of the corresponding angle range can be generated according to the specific workpiece pertinence, the template cluster in the range of 0-360 degrees is not required to be manufactured on any workpiece, the number of the template clusters is effectively reduced, and the template matching efficiency is improved.
Description
Technical Field
The invention relates to the technical field of template manufacturing, in particular to a method and a device for generating a workpiece template and electronic equipment.
Background
In an automatic production line, such as automatic production lines for material grabbing, sorting, size detection, integrity detection, object identification, groove reinstalling and the like, a template matching link is often involved, and template matching is a technology for searching the best matching (or similar) part of another template image in one image. Template preparation is a prerequisite for template matching.
At present, template generation methods are generally divided into two types, one type is a camera image-based template generation method, the method directly processes images acquired by a camera, and the acquired template images need to generate templates matched with real workpieces through calibration and affine algorithms, so that the method is not suitable for automatic production lines with high precision requirements.
The other method is a method for generating a template according to the size contour information of the workpiece CAD file, and the method firstly needs to create a background image with fixed size, then reads the CAD file of the workpiece, closes the adjacent contour in the CAD file, then extracts each closed contour, redraws a contour image containing each closed contour on the background image, and finally generates the template in a fixed angle range by using the redrawn contour image. It is easy to find that the template image obtained by the method when the workpiece with an overlarge size is drawn is incomplete due to the fixed size of the background image, and the background image occupies too much space and occupies a memory amount when the workpiece with a smaller size is drawn. Meanwhile, the method does not consider the geometric characteristics of the workpiece when the template is constructed, and the number of the obtained template clusters is large, so that the efficiency of the template matching process is low.
Therefore, a template generation method capable of adapting to the size and geometric characteristics of the workpiece is needed to solve the above problems.
Disclosure of Invention
The invention provides a method and a device for generating a workpiece template and electronic equipment, which are used for solving the defects of low template matching efficiency caused by the fact that the size of a workpiece is not considered in a background image of a workpiece template generation mode and the number of template clusters is large in the prior art.
In a first aspect, the present invention provides a method for generating a workpiece template, the method comprising:
constructing a background image of a target workpiece;
constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image;
judging the geometric characteristics of the target workpiece;
determining the angle range of the template cluster according to the geometric characteristics of the target workpiece;
and generating a template cluster of a corresponding type through the template image according to the angle range of the template cluster.
According to the method for generating the workpiece template provided by the invention, the constructing of the background image of the target workpiece comprises the following steps:
and acquiring the contour information of the target workpiece, and constructing a background image with a corresponding size according to the contour information of the target workpiece.
According to the method for generating the workpiece template provided by the invention, the step of acquiring the contour information of the target workpiece and constructing the background image with the corresponding size according to the contour information of the target workpiece comprises the following steps:
reading drawing source file data of a target workpiece to obtain contour information of the target workpiece;
connecting adjacent contours in the contour information of the target workpiece to form a closed contour;
extracting the closed contour with the longest length, and calculating the size of a circumscribed rectangle of the closed contour with the longest length;
and constructing and obtaining a background image with a corresponding size according to the size of the circumscribed rectangle.
According to the method for generating the workpiece template provided by the invention, the judging the geometric characteristics of the target workpiece comprises the following steps:
and respectively judging whether the target workpiece is in central symmetry, horizontal symmetry and vertical symmetry according to the template image.
According to the method for generating the workpiece template provided by the invention, whether the target workpiece is in central symmetry, horizontal symmetry and vertical symmetry or not is respectively judged according to the template image, and the method comprises the following steps:
performing centrosymmetric affine transformation on the template image to obtain a centrosymmetric transformation image;
comparing the central symmetry transformation diagram with the template image, and judging whether the target workpiece is in central symmetry;
performing horizontal symmetric affine transformation on the template image to obtain a horizontal affine transformation image;
comparing the horizontal affine transformation graph with the template image, and judging whether the target workpiece is horizontally symmetrical;
performing vertical symmetric affine transformation on the template image to obtain a vertical affine transformation image;
and comparing the vertical affine transformation graph with the template image, and judging whether the target workpiece is vertically symmetrical.
According to the method for generating the workpiece template provided by the invention, the determining the angle range of the template cluster according to the geometric characteristics of the target workpiece comprises the following steps:
if the target workpiece is centrosymmetric, the angle range of the template cluster is 00-900;
If the target workpiece is horizontally symmetrical or vertically symmetrical, the angle range of the template cluster is 00-1800;
If the target workpiece is not centrosymmetric, horizontally symmetric and vertically symmetric, the angle range of the template cluster is 00-3600。
According to the method for generating the workpiece template provided by the invention, the template cluster of the corresponding type is generated through the template image according to the angle range of the template cluster, and the method comprises the following steps:
if the target workpiece is centrosymmetric, horizontally symmetric or vertically symmetric, generating a single template cluster through the template image;
and if the target workpiece is not centrosymmetric, not horizontally symmetric and not vertically symmetric, generating a double-template cluster through the template image.
According to the method for generating the workpiece template provided by the invention, the step of constructing the corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image to obtain the template image comprises the following steps:
connecting adjacent contours in the contour information of the target workpiece to form a closed contour;
dividing the closed profile into an inner profile and an outer profile;
and filling the inner contour and the outer contour through different filling colors which are different from the background image to obtain a template image.
In a second aspect, the present invention also provides an apparatus for generating a workpiece template, the apparatus comprising:
the background construction module is used for constructing a background image of the target workpiece;
the template image construction module is used for constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image and obtaining a template image;
the geometric characteristic judging module is used for judging the geometric characteristic of the target workpiece;
the angle range determining module is used for determining the angle range of the template cluster according to the geometric characteristics of the target workpiece;
and the template cluster generating module is used for generating template clusters of corresponding types through the template images according to the angle ranges of the template clusters.
In a third aspect, the present invention further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the workpiece template generating method according to any one of the above aspects.
According to the workpiece template generation method, the workpiece template generation device and the electronic equipment, the geometric characteristics of the target workpiece are judged, the angle range of the template cluster is determined based on the geometric characteristics of the target workpiece, and then the template cluster of the corresponding type is generated.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flow chart illustrating a prior art method for generating a workpiece template based on a CAD file;
FIG. 2 is a flow chart of a method for generating a workpiece template according to the present invention;
FIG. 3 is a second flowchart illustrating a method for generating a workpiece template according to the present invention;
FIG. 4 is a schematic structural diagram of an apparatus for generating a workpiece template according to the present invention;
fig. 5 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Before describing the method for generating a workpiece template according to an embodiment of the present invention, a description will be given of an existing method for generating a workpiece template based on a CAD file.
Referring to fig. 1, a conventional method for generating a workpiece template based on a CAD file includes:
step 110: a blank gray scale image of a fixed image size is first created, which may be a background image with black gray scale.
Step 120: the contour information of the structure in the CAD file of the workpiece is then read.
Step 130: the adjacent contours in the CAD file are closed and affine transformed to the image center.
Step 140: redrawing a contour image of the workpiece, extracting each closed contour, and drawing each closed contour on the background image using a different gray level than the background image to generate a template image. With the template image, templates of different angles and scales can be generated for subsequent matching techniques.
Step 150: a single edge gradient vector template cluster of a fixed angular range is generated using the redrawn image.
The method for generating the workpiece template based on the CAD file has the following three problems:
first, what size should be to create a gray scale, such as 2000 x 2000 workpiece size, results in a 500 x 2000 image, which results in no workpiece being drawn at all on the background image.
Second, how large the second created template should generate, if the matched target is laid out randomly, this requires generating angles in all directions, assuming that 0 to 360 degrees are generated, every 0.2 degrees, and a total of 1800 template clusters need to be generated.
Thus, when the templates are matched, the most similar template needs to be found from the 1800 generated template clusters. E.g., a perfectly centrosymmetric workpiece, 1800 template clusters are not actually needed at all, and only 0 to 90 degree templates need to be generated enough.
Thirdly, executing a template cluster which can only generate one template image once, and restarting template generation once for a mirror-symmetric workpiece by using a CAD file of the mirror image, so that the template generation operation is too complicated.
Therefore, the embodiment of the invention improves the method for generating the workpiece template based on the CAD file, and obtains the method for generating the workpiece template as described below.
Fig. 2 and 3 illustrate a method for generating a workpiece template according to an embodiment of the present invention, the method including:
step 210: and constructing a background image of the target workpiece.
Specifically, the process of constructing the background image of the target workpiece in this embodiment includes:
and acquiring the contour information of the target workpiece, and constructing a background image with a corresponding size according to the contour information of the target workpiece.
Further, the process of obtaining the contour information of the target workpiece and constructing the background image with the corresponding size according to the contour information of the target workpiece specifically includes:
firstly, reading drawing source file data of a target workpiece to obtain contour information of the target workpiece; the drawing source file data refers to workpiece contour data in a dxf file format of a CAD file.
Then, connecting adjacent outlines in the outline information of the target workpiece to form a closed outline; if the distance d between two close end points of adjacent contour lines satisfies that d is more than or equal to 1 and less than or equal to 2, the two end points can be connected to form a closed contour line.
Then, extracting the closed contour with the longest length, and calculating the size of a circumscribed rectangle of the closed contour with the longest length; in the process, the closed contour with the maximum length is found firstly, and the width R of the circumscribed rectangle of the maximum closed contour in the maximum direction is calculatedwAnd a height Rh。
Finally, a background image with a corresponding size is constructed and obtained according to the size of the circumscribed rectangle, in this embodiment, the k times of the width and the height of the circumscribed rectangle are specifically used as the size of the background image, and the calculation formula is as follows:
Iw=kRw (1)
Ih=kRh (2)
wherein, IwWidth of background image, IhRepresenting the height of the background image, k ∈ [1,2 ]]。
It is easy to find that, in the background image construction method provided by this embodiment, a fixed background image size is not used, but the size of the background image is adaptively created according to the size of the maximum circumscribed rectangle of the workpiece, so that workpieces of different sizes can be compatible, and the amount of memory for storing the image can be effectively reduced for a production line required to store the template image.
Step 220: and constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image.
The construction process of the template image specifically includes:
first, adjacent contours in the contour information of the target workpiece are connected to form a closed contour.
The closed contour is then divided into an inner contour and an outer contour.
And filling the inner contour and the outer contour through different filling colors different from the background image to obtain a template image.
In this embodiment, the gray value of the background image is set to 0, that is, the background is black, then each outer contour is filled with non-0 gray, the outer contour is generally filled with a filling color with a gray value of 255, then the inner contour is filled with a filling color with a gray value of non-0 gray and a gray value of 255, and the inner contour is generally filled with a color with a gray value of 125, so as to form the template image.
Step 230: and judging the geometric characteristics of the target workpiece.
Specifically, the process of determining the geometric characteristics of the target workpiece includes:
and respectively judging whether the target workpiece is in central symmetry, horizontal symmetry and vertical symmetry according to the template image.
Further, according to the template image, whether the target workpiece is in central symmetry, horizontal symmetry and vertical symmetry is respectively judged, including:
firstly, the template image is subjected to centrosymmetric affine transformation to obtain a centrosymmetric transformation image.
And then, comparing the centrosymmetric transformation diagram with the template image, judging whether the target workpiece is centrosymmetric, specifically, subtracting the binarization region of the template image from the binarization region of the centrosymmetric transformation diagram to obtain a region difference, calculating the area of the region difference, and if the area of the region difference is equal to zero, determining that the workpiece is a centrosymmetric workpiece.
And then, carrying out horizontal symmetric affine transformation on the template image to obtain a horizontal affine transformation image.
And then, comparing the horizontal affine transformation image with the template image, judging whether the target workpiece is horizontally symmetrical, specifically, subtracting the binarization area of the template image from the binarization area of the horizontal affine transformation image to obtain an area difference, calculating the area of the area difference, and if the area of the area difference is equal to zero, determining that the workpiece is a horizontally symmetrical piece.
And then, performing vertical symmetric affine transformation on the template image to obtain a vertical affine transformation image.
And finally, comparing the vertical affine transformation image with the template image, judging whether the target workpiece is vertically symmetrical, specifically, subtracting the binarization area of the template image from the binarization area of the vertical affine transformation image to obtain an area difference, calculating the area of the area difference, and if the area of the area difference is equal to zero, determining that the workpiece is a vertically symmetrical part.
Step 240: and determining the angle range of the template cluster according to the geometric characteristics of the target workpiece.
Specifically, determining the angular range of the template cluster according to the geometric characteristics of the target workpiece includes:
if the target workpiece is centrosymmetric, the angle range of the template cluster is 00-900;
If the target workpiece is horizontally symmetrical or vertically symmetrical, the angle range of the template cluster is 00-1800;
If the target workpiece is not centrosymmetric, horizontally symmetric and vertically symmetric, the angle range of the template cluster is 00-3600。
This exampleAnd determining the angle range of the template clusters according to the geometric characteristics of the workpiece, and mainly generating the number of the template clusters for optimizing the template image. For a centrosymmetric, horizontally symmetric, vertically symmetric workpiece, it is not necessary to generate a [0 ]0,3600]Template clusters at intervals θ (threshold set according to angular accuracy).
If the template is generated according to the conventional method, the actual placing direction of the workpiece to be measured is not determined, and the position needs to be in [0 ]0,3600]Finding at fixed theta angles at intervals, e.g. at [0 ]0,3600]The template cluster generation is carried out at intervals of 0.2 degrees, and the template images are required to be rotated by 360 degrees at intervals of 0.2 degrees01800 times, creating a new template image every rotation, creating one template, for a total of 1800 template clusters. When the templates are matched, the images to be detected need to be compared 1800 times.
If the workpiece is centrosymmetric, only 90 is generated0And 0.2-450 template clusters, and when the templates are matched, the image to be detected only needs to be compared 450 times. Therefore, the template matching efficiency can be effectively improved. According to the embodiment, the angle range of the template cluster to be created is generated in a self-adaptive manner according to the geometric characteristics of the workpiece without manual participation by automatically judging whether the workpiece is in central symmetry, horizontal symmetry or vertical symmetry. The number of template clusters generated by the workpieces which are centrosymmetric, horizontally symmetric or vertically symmetric is effectively reduced, and the time efficiency of matching the workpieces which are centrosymmetric, horizontally symmetric or vertically symmetric is improved.
Step 250: and generating the template cluster of the corresponding type through the template image according to the angle range of the template cluster.
Specifically, according to the angle range of the template cluster, generating a corresponding type of template cluster through the template image, including:
if the target workpiece is centrosymmetric, horizontally symmetric or vertically symmetric, directly generating a single template cluster through the template image;
and if the target workpiece is not centrosymmetric, not horizontally symmetric and not vertically symmetric, generating a double-template cluster through the template image.
In this embodiment, the process of generating a dual template cluster is as follows:
firstly, a first group of single template clusters are generated by using template images, then mirror image overturning and affine transformation are carried out on the template images to generate mirror image template images, and a second group of single template clusters are generated by using the mirror image template images to obtain double template clusters.
The determination link of the template cluster type can generate the template cluster of the mirror image symmetrical parts of the non-center, horizontal and vertical symmetrical workpieces at one time, so that when the non-center, horizontal and vertical symmetrical workpieces are produced, the workpieces which are mutually mirror images are placed in the material frame at the same time, if the left and right vehicle doors are mirror images, even if the workpieces are mirror images, the models are different, and thus, the two workpieces with different models can be identified at the same time by using the tool for manufacturing the template only once.
The following describes a device for generating a workpiece template according to the present invention, and the device for generating a workpiece template described below and the method for generating a workpiece template described above may be referred to in correspondence with each other.
Fig. 4 shows an apparatus for generating a workpiece template according to an embodiment of the present invention, the apparatus including:
a background construction module 410 for constructing a background image of the target workpiece;
the template image construction module 420 is configured to construct a corresponding closed contour according to the contour information of the target workpiece, redraw and fill the closed contour in the background image, and obtain a template image;
a geometric characteristic determination module 430 for determining geometric characteristics of the target workpiece;
an angle range determination module 440, configured to determine an angle range of the template cluster according to a geometric characteristic of the target workpiece;
and a template cluster generating module 450, configured to generate a template cluster of a corresponding type from the template image according to the angle range of the template cluster.
Specifically, the background constructing module 410 in this embodiment includes:
and the construction unit is used for acquiring the contour information of the target workpiece and constructing a background image with a corresponding size according to the contour information of the target workpiece.
Further, the above-mentioned building unit specifically includes:
the contour extraction subunit is used for reading in drawing source file data of the target workpiece to obtain contour information of the target workpiece;
the closed contour subunit is used for connecting adjacent contours in the contour information of the target workpiece to form a closed contour;
the circumscribed rectangle subunit is used for extracting the closed contour with the longest length and calculating the size of the circumscribed rectangle of the closed contour with the longest length;
and the background establishing subunit is used for establishing and obtaining a background image with a corresponding size according to the size of the circumscribed rectangle.
Specifically, the template image constructing module 420 in this embodiment includes:
the contour processing unit is used for connecting adjacent contours in the contour information of the target workpiece to form a closed contour;
the contour dividing unit is used for dividing the closed contour into an inner contour and an outer contour;
and the template image establishing unit is used for filling the inner contour and the outer contour through different filling colors which are different from the background image to obtain a template image.
Specifically, the geometric characteristic determining module 430 in this embodiment includes:
and the judging unit is used for respectively judging whether the target workpiece is in central symmetry, horizontal symmetry and vertical symmetry according to the template image.
Further, the determination unit includes:
the central transformation subunit is used for performing central symmetric affine transformation on the template image to obtain a central symmetric transformation image;
the center judging subunit is used for comparing the centrosymmetric transformation diagram with the template image and judging whether the target workpiece is centrosymmetric;
the horizontal transformation subunit is used for performing horizontal symmetric affine transformation on the template image to obtain a horizontal affine transformation image;
the horizontal judgment subunit is used for comparing the horizontal affine transformation diagram with the template image and judging whether the target workpiece is horizontally symmetrical or not;
the vertical transformation subunit is used for performing vertical symmetric affine transformation on the template image to obtain a vertical affine transformation image;
and the vertical judging subunit is used for comparing the vertical affine transformation diagram with the template image and judging whether the target workpiece is vertically symmetrical.
Specifically, the angle range determining module 440 in this embodiment includes:
a first angle determining unit for determining the angle range of the template cluster to be 0 when the target workpiece is centrosymmetric0-900;
A second angle determining unit for determining the angle range of the template cluster to be 00-1800;
A third angle determining unit for determining the angle range of the template cluster as 00-3600。
Specifically, the template cluster generating module 450 in this embodiment includes:
the first generation unit is used for generating a single template cluster through the template image when the target workpiece is in central symmetry, horizontal symmetry or vertical symmetry;
and the second generation unit is used for generating a double template cluster through the template image when the target workpiece is not centrosymmetric, not horizontally symmetric and not vertically symmetric.
Therefore, the workpiece template generation device provided by the embodiment of the invention can adaptively create the background image according to the width and the height of the circumscribed rectangle of the maximum outline of the workpiece, adaptively determine the angle range of the created template cluster according to the geometric characteristics of the workpiece, and determine whether to generate the double-template cluster, thereby effectively improving the adaptability of the workpiece creation template with size diversity, reducing the matching time and the modeling operation flow through the angle range of the adaptive template cluster and the mode of adaptively generating the single-template cluster and the double-template cluster, improving the accuracy of template manufacture, effectively reducing the number of the template clusters, and improving the identification efficiency of the specific workpiece.
Fig. 5 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 5: a processor (processor)510, a communication Interface (Communications Interface)520, a memory (memory)530 and a communication bus 540, wherein the processor 510, the communication Interface 520 and the memory 530 communicate with each other via the communication bus 540. The processor 510 may invoke logic instructions in the memory 530 to perform a method of generating a workpiece template, the method comprising: constructing a background image of a target workpiece; constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image; judging the geometric characteristics of the target workpiece; determining the angle range of the template cluster according to the geometric characteristics of the target workpiece; and generating the template cluster of the corresponding type through the template image according to the angle range of the template cluster.
Furthermore, the logic instructions in the memory 530 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the method for generating a workpiece template provided by the above methods, the method comprising: constructing a background image of a target workpiece; constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image; judging the geometric characteristics of the target workpiece; determining the angle range of the template cluster according to the geometric characteristics of the target workpiece; and generating the template cluster of the corresponding type through the template image according to the angle range of the template cluster.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program, which when executed by a processor is implemented to perform the method for generating a workpiece template provided above, the method comprising: constructing a background image of a target workpiece; constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image; judging the geometric characteristics of the target workpiece; determining the angle range of the template cluster according to the geometric characteristics of the target workpiece; and generating the template cluster of the corresponding type through the template image according to the angle range of the template cluster.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (10)
1. A method of generating a workpiece template, comprising:
constructing a background image of a target workpiece;
constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image;
judging the geometric characteristics of the target workpiece;
determining the angle range of the template cluster according to the geometric characteristics of the target workpiece;
and generating a template cluster of a corresponding type through the template image according to the angle range of the template cluster.
2. The method of claim 1, wherein the constructing a background image of the target workpiece comprises:
and acquiring the contour information of the target workpiece, and constructing a background image with a corresponding size according to the contour information of the target workpiece.
3. The method for generating the workpiece template as claimed in claim 2, wherein the obtaining of the contour information of the target workpiece and the constructing of the background image of the corresponding size according to the contour information of the target workpiece comprise:
reading drawing source file data of a target workpiece to obtain contour information of the target workpiece;
connecting adjacent contours in the contour information of the target workpiece to form a closed contour;
extracting the closed contour with the longest length, and calculating the size of a circumscribed rectangle of the closed contour with the longest length;
and constructing and obtaining a background image with a corresponding size according to the size of the circumscribed rectangle.
4. The method of claim 1, wherein said determining the geometric characteristic of the target workpiece comprises:
and respectively judging whether the target workpiece is in central symmetry, horizontal symmetry and vertical symmetry according to the template image.
5. The method of claim 4, wherein the determining whether the target workpiece is centrally symmetric, horizontally symmetric, and vertically symmetric according to the template image comprises:
performing centrosymmetric affine transformation on the template image to obtain a centrosymmetric transformation image;
comparing the central symmetry transformation diagram with the template image, and judging whether the target workpiece is in central symmetry;
performing horizontal symmetric affine transformation on the template image to obtain a horizontal affine transformation image;
comparing the horizontal affine transformation graph with the template image, and judging whether the target workpiece is horizontally symmetrical;
performing vertical symmetric affine transformation on the template image to obtain a vertical affine transformation image;
and comparing the vertical affine transformation graph with the template image, and judging whether the target workpiece is vertically symmetrical.
6. The method of claim 4, wherein determining the angular extent of a template cluster based on the geometric characteristics of the target workpiece comprises:
if the target workpiece is centrosymmetric, the angle range of the template cluster is 0-90 degrees;
if the target workpiece is horizontally symmetrical or vertically symmetrical, the angle range of the template cluster is 0-180 degrees;
if the target workpiece is not centrosymmetric, horizontally symmetric and vertically symmetric, the angle range of the template cluster is 0-360 degrees.
7. The method for generating the workpiece template according to claim 4, wherein the generating the corresponding type of template cluster through the template image according to the angle range of the template cluster comprises:
if the target workpiece is centrosymmetric, horizontally symmetric or vertically symmetric, generating a single template cluster through the template image;
and if the target workpiece is not centrosymmetric, not horizontally symmetric and not vertically symmetric, generating a double-template cluster through the template image.
8. The method for generating a workpiece template according to claim 1, wherein the constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image, and obtaining a template image comprises:
connecting adjacent contours in the contour information of the target workpiece to form a closed contour;
dividing the closed profile into an inner profile and an outer profile;
and filling the inner contour and the outer contour through different filling colors which are different from the background image to obtain a template image.
9. An apparatus for generating a workpiece template, comprising:
the background construction module is used for constructing a background image of the target workpiece;
the template image construction module is used for constructing a corresponding closed contour according to the contour information of the target workpiece, redrawing and filling the closed contour in the background image and obtaining a template image;
the geometric characteristic judging module is used for judging the geometric characteristic of the target workpiece;
the angle range determining module is used for determining the angle range of the template cluster according to the geometric characteristics of the target workpiece;
and the template cluster generating module is used for generating template clusters of corresponding types through the template images according to the angle ranges of the template clusters.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor, when executing the program, carries out the steps of the method for generating a workpiece template according to any of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111302266.8A CN114003978A (en) | 2021-11-04 | 2021-11-04 | Workpiece template generation method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111302266.8A CN114003978A (en) | 2021-11-04 | 2021-11-04 | Workpiece template generation method and device and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114003978A true CN114003978A (en) | 2022-02-01 |
Family
ID=79927604
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111302266.8A Pending CN114003978A (en) | 2021-11-04 | 2021-11-04 | Workpiece template generation method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114003978A (en) |
-
2021
- 2021-11-04 CN CN202111302266.8A patent/CN114003978A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107633192B (en) | Bar code segmentation and reading method based on machine vision under complex background | |
JP2019032830A (en) | Systems and methods for detecting grasp poses for handling target objects | |
CN111681162B (en) | Defect sample generation method and device, electronic equipment and storage medium | |
US11543800B2 (en) | Method of printing a 3D model from point cloud data | |
CN107169489B (en) | Method and apparatus for tilt image correction | |
CN114581742A (en) | Linearity-based connected domain clustering fusion method, device, system and medium | |
CN113592886B (en) | Drawing examining method and device for building drawing, electronic equipment and medium | |
CN114742789B (en) | General part picking method and system based on surface structured light and electronic equipment | |
CN108447094B (en) | Method and system for estimating attitude of monocular color camera | |
CN112132907A (en) | Camera calibration method and device, electronic equipment and storage medium | |
CN115641332A (en) | Method, device, medium and equipment for detecting product edge appearance defects | |
CN112053427A (en) | Point cloud feature extraction method, device, equipment and readable storage medium | |
CN105354816B (en) | Electronic component positioning method and device | |
CN116309817A (en) | Tray detection and positioning method based on RGB-D camera | |
CN116597466A (en) | Engineering drawing text detection and recognition method and system based on improved YOLOv5s | |
CN116542926B (en) | Method, device, equipment and storage medium for identifying defects of two-dimension codes of battery | |
CN117523087B (en) | Three-dimensional model optimization method based on content recognition | |
CN112767412B (en) | Vehicle part classification method and device and electronic equipment | |
CN114290660A (en) | Curved surface layered 3D printing method and system | |
CN117173090A (en) | Welding defect type identification method and device, storage medium and electronic equipment | |
CN114003978A (en) | Workpiece template generation method and device and electronic equipment | |
CN115564779A (en) | Part defect detection method and device and storage medium | |
CN115063405A (en) | Method, system, electronic device and storage medium for detecting defects on surface of steel | |
CN116681792A (en) | Subgraph generation method, device and equipment of vector drawing and readable storage medium | |
WO2022143261A1 (en) | Grid map quality evaluation method and apparatus, computer device, and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |