CN115131582A - Target recognition method, device and medium based on morphological recognition template matching - Google Patents
Target recognition method, device and medium based on morphological recognition template matching Download PDFInfo
- Publication number
- CN115131582A CN115131582A CN202210850252.8A CN202210850252A CN115131582A CN 115131582 A CN115131582 A CN 115131582A CN 202210850252 A CN202210850252 A CN 202210850252A CN 115131582 A CN115131582 A CN 115131582A
- Authority
- CN
- China
- Prior art keywords
- target
- image
- threshold
- pixel
- binarized
- 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
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/56—Extraction of image or video features relating to colour
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/26—Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/82—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Evolutionary Computation (AREA)
- Multimedia (AREA)
- Computing Systems (AREA)
- Artificial Intelligence (AREA)
- General Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Databases & Information Systems (AREA)
- Life Sciences & Earth Sciences (AREA)
- Medical Informatics (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Molecular Biology (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Image Analysis (AREA)
Abstract
本申请提出了一种基于形态学识别模板匹配的目标识别方法,包括:S1、获取原始图像;S2、将所述原始图像从RGB格式转为YCBCR格式,并对转格式后的所述原始图像进行二值化处理,得到二值化图像,根据各种颜色所对应的YCBCR的第一阈值,从所述二值化图像中依次筛选出大于对应所述第一阈值的像素点;S3、判断两个所述像素点之间的距离是否大于第二阈值,若是,则两个所述像素点对应不同的目标,若否,则两个所述像素点为同一个目标,并生成新的第二阈值;S4、将所述二值化图像与各种目标的二值化模板图像进行匹配,从而确定所述二值化图像中存在的各个目标对应的类型。本申请将目标的颜色、数量、种类识别综合为一体,并且资源使用小,适用于简单的使用场景。
The present application proposes a target recognition method based on morphological recognition template matching, including: S1, obtaining an original image; S2, converting the original image from RGB format to YCBCR format, and converting the original image in the format Perform binarization processing to obtain a binarized image, and according to the first threshold of YCBCR corresponding to each color, screen out the pixels larger than the corresponding first threshold from the binarized image in turn; S3, determine Whether the distance between the two pixels is greater than the second threshold, if so, the two pixels correspond to different targets, if not, the two pixels are the same target, and a new first is generated. Two thresholds; S4 , matching the binarized image with the binarized template images of various targets, so as to determine the type corresponding to each target existing in the binarized image. This application integrates the identification of the color, quantity and type of the target into one, and the resource usage is small, which is suitable for simple usage scenarios.
Description
技术领域technical field
本申请涉及目标识别的技术领域,具体涉及一种基于形态学识别模板匹配的目标识别方法、装置及介质。The present application relates to the technical field of target recognition, in particular to a target recognition method, device and medium based on morphological recognition template matching.
背景技术Background technique
当今社会随着科学技术的发展,目标识别算法逐步的走向成熟,对于摄像头视频流的帧信号处理识别一直是热点问题。物品识别是智能机器的基本功能之一,该功能无论在军事还是民用中都有着广泛的应用场景,比如智能视频监控,无人驾驶,各类身份识别,计算机取证等。With the development of science and technology in today's society, the target recognition algorithm is gradually becoming mature, and the frame signal processing and recognition of the camera video stream has always been a hot issue. Item recognition is one of the basic functions of intelligent machines. This function has a wide range of application scenarios in both military and civilian applications, such as intelligent video surveillance, unmanned driving, various types of identification, and computer forensics.
计算机的图像识别发展到目前也存在很多不同的技术方法,大致可以分为传统的图像识别方法和在其基础上融合神经网络算法的识别方式。神经网络图像识别技术是一种比较新型的图像识别技术,在神经网络图像识别技术中,以卷积神经网络为基础结合形成的深度学习模型可谓是人工智能领域的新星,在诸多人工智能领域,特别是图像识别领域取得了令人瞩目的进展。基于神经网络的图像识别算法虽然准确度方面比较好,但是耗费过多的硬件资源,只有在一些要求高准确率的场合比较适用,而对于一些比较简单的使用场景,却不具有实用性。There are many different technical methods in the development of computer image recognition, which can be roughly divided into traditional image recognition methods and recognition methods based on the fusion of neural network algorithms. Neural network image recognition technology is a relatively new type of image recognition technology. In neural network image recognition technology, the deep learning model based on the combination of convolutional neural network can be described as a new star in the field of artificial intelligence. In particular, impressive progress has been made in the field of image recognition. Although the image recognition algorithm based on neural network is relatively good in accuracy, it consumes too much hardware resources.
因此,本申请在于选用传统识别方式,在使用场景比较简单的情况下,使用较少的硬件资源实现目标识别。Therefore, the present application is to select the traditional identification method, and use less hardware resources to realize target identification under the condition that the usage scenario is relatively simple.
发明内容SUMMARY OF THE INVENTION
为了解决现有上述技术问题,本申请提出了一种基于形态学识别模板匹配的目标识别方法、装置及介质。In order to solve the above-mentioned technical problems in the prior art, the present application proposes a target recognition method, device and medium based on morphological recognition template matching.
根据本申请的第一方面,提出了一种基于形态学识别模板匹配的目标识别方法,包括以下步骤:According to the first aspect of the present application, a target recognition method based on morphological recognition template matching is proposed, which includes the following steps:
S1、获取原始图像;S1. Obtain the original image;
S2、将所述原始图像从RGB格式转为YCBCR格式,并对转格式后的所述原始图像进行二值化处理,得到二值化图像,根据各种颜色所对应的YCBCR的第一阈值,从所述二值化图像中依次筛选出大于对应所述第一阈值的像素点;S2. Convert the original image from RGB format to YCBCR format, and perform binarization processing on the converted original image to obtain a binarized image. According to the first threshold of YCBCR corresponding to various colors, Screen out the pixels larger than the corresponding first threshold in sequence from the binarized image;
S3、判断两个所述像素点之间的距离是否大于第二阈值,若是,则两个所述像素点对应不同的目标,若否,则两个所述像素点为同一个目标,并生成新的第二阈值;以及S3. Determine whether the distance between the two pixel points is greater than the second threshold. If so, the two pixel points correspond to different targets. If not, the two pixel points are the same target, and generate a new second threshold; and
S4、将所述二值化图像与各种目标的二值化模板图像进行匹配,从而确定所述二值化图像中存在的各个目标对应的类型。S4. Match the binarized image with the binarized template images of various targets, so as to determine the type corresponding to each target existing in the binarized image.
优选的,所述步骤S2-S4是在FPGA开发板上实现的。Preferably, the steps S2-S4 are implemented on an FPGA development board.
优选的,在所述步骤S2中,每筛选出一个所述像素点,对应生成一个相应颜色的使能信号;在所述步骤S3中,初始化多个按顺序排列的候选框,在第一个像素点出现时,根据对应的所述使能信号对第一个候选框进行赋值,从而在所述二值化图像的该像素点位置上框选出带有相应颜色的检测框。Preferably, in the step S2, each time a pixel is screened out, an enable signal of a corresponding color is correspondingly generated; in the step S3, a plurality of candidate frames arranged in sequence are initialized, and in the first When a pixel point appears, assign a value to the first candidate frame according to the corresponding enable signal, so that a detection frame with a corresponding color is framed at the position of the pixel point in the binarized image.
优选的,在所述步骤S3中,当出现一个新的像素点时,判断新的像素点是否在任意一个旧的像素点对应的检测框内,若是,则新的像素点与该旧的像素点属于同一个目标,将新的像素点作为该旧的像素点对应的检测框的边界,若否,则根据新的像素点对应的所述使能信号对下一个候选框进行赋值,从而在所述二值化图像对应新的像素点位置上框选出带有相应颜色的检测框;其中,所述第二阈值为每个带有检测框的像素点与其检测框上下左右边界之间的距离。Preferably, in the step S3, when a new pixel appears, it is judged whether the new pixel is in the detection frame corresponding to any old pixel, if so, the new pixel is the same as the old pixel. The points belong to the same target, and the new pixel point is used as the boundary of the detection frame corresponding to the old pixel point. If not, the next candidate frame is assigned according to the enable signal corresponding to the new pixel point. The binarized image corresponds to a new pixel position and selects a detection frame with a corresponding color; wherein, the second threshold is the difference between each pixel with a detection frame and the upper, lower, left, and right boundaries of the detection frame. distance.
优选的,所述步骤S4具体包括:根据所述步骤S3中判断得到的各个目标,将所述二值化图像分割成对应各个目标的目标图像,且所述目标图像与各种目标的所述二值化模板图像大小相同,将所述目标图像与各种目标的所述二值化模板图像进行匹配,从而确定各个目标对应的类型。Preferably, the step S4 specifically includes: according to each target determined in the step S3, dividing the binarized image into target images corresponding to each target, and the target image and the various targets The size of the binarized template images is the same, and the target image is matched with the binarized template images of various targets, so as to determine the type corresponding to each target.
优选的,所述检测框的生成过程具体包括:以行左边框和场左边框为左上边框点,扫描生成500*500像素值大小的所述检测框,以使对应的像素点落在所述检测框的中心。Preferably, the generation process of the detection frame specifically includes: taking the left border of the row and the left border of the field as the upper left border points, scanning to generate the detection frame with a size of 500*500 pixels, so that the corresponding pixel points fall on the The center of the detection box.
优选的,所述步骤S2中所述原始图像从RGB格式转为YCBCR格式的公式具体为:Preferably, the formula for converting the original image from the RGB format to the YCBCR format in the step S2 is specifically:
Y=0.183R+0.614G+0.062B+16Y=0.183R+0.614G+0.062B+16
CB=-0.101R-0.338G+0.439B+128CB=-0.101R-0.338G+0.439B+128
CR=0.439R-0.399G-0.040B+128。CR=0.439R-0.399G-0.040B+128.
根据本申请的第二方面,提出了一种基于形态学识别模板匹配的目标识别装置,包括:According to a second aspect of the present application, a target recognition device based on morphological recognition template matching is proposed, including:
图像获取模块,配置应用获取原始图像;Image acquisition module, configure the application to acquire the original image;
颜色识别模块,配置用于将所述原始图像从RGB格式转为YCBCR格式,并对转格式后的所述原始图像进行二值化处理,得到二值化图像,根据各种颜色所对应的YCBCR的第一阈值,从所述二值化图像中依次筛选出大于对应所述第一阈值的像素点;The color recognition module is configured to convert the original image from RGB format to YCBCR format, and perform binarization processing on the converted original image to obtain a binarized image. According to the YCBCR corresponding to each color the first threshold of , and sequentially filter out the pixels larger than the corresponding first threshold from the binarized image;
数量识别模块,配置用于判断两个所述像素点之间的距离是否大于第二阈值,若是,则两个所述像素点对应不同的目标,若否,则两个所述像素点为同一个目标,并生成新的第二阈值;A quantity identification module, configured to judge whether the distance between the two pixel points is greater than the second threshold, if so, the two pixel points correspond to different targets, if not, the two pixel points are the same a target and generate a new second threshold;
模板匹配模块,配置用于将所述二值化图像与各种目标的二值化模板图像进行匹配,从而确定所述二值化图像中存在的各个目标对应的类型。The template matching module is configured to match the binarized image with the binarized template images of various targets, so as to determine the type corresponding to each target existing in the binarized image.
优选的,所述颜色识别模块设置有多个,每个所述颜色识别模块对应筛选一种颜色的像素点。Preferably, there are multiple color identification modules, and each of the color identification modules corresponds to screening pixels of one color.
根据本申请的第三方面,提出了一种计算机可读储存介质,其储存有计算机程序,所述计算机程序在被处理器执行时实施如本申请第一方面所述的基于形态学识别模板匹配的目标识别方法。According to a third aspect of the present application, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the template matching based on morphology recognition as described in the first aspect of the present application target recognition method.
本申请提出了一种基于形态学识别模板匹配的目标识别方法、装置及介质,先对图像进行RGB转YCBCR格式处理以及二值化处理,然后对每种颜色对应的YCBCR阈值进行分割,从而筛选出图像中对应各种颜色的像素点,实现颜色识别;筛选出像素点后,通过判断两个像素点之间的距离是否大于阈值,从而可以判断新的像素点是否为新的目标,实现数量识别;最后将判断得到的各个目标的目标图像与预先放入的各种目标的二值化模板图像进行一一匹配,从而实现图像中各个目标的种类识别。本申请不仅做到将目标的颜色、数量、种类识别综合为一体,并且相比于传统的神经网络目标识别算法,其资源使用较小,可在FPGA开发板上运行,适用于各种简单的使用场景。This application proposes a target recognition method, device and medium based on morphological recognition template matching. First, the image is processed in RGB to YCBCR format and binarized, and then the YCBCR threshold corresponding to each color is segmented, so as to filter The pixels corresponding to various colors in the image are obtained to realize color recognition; after filtering out the pixels, by judging whether the distance between the two pixels is greater than the threshold, it can be judged whether the new pixel is a new target, and the number of achieved Recognition; finally, the target image of each target obtained by judgment is matched with the pre-placed binarized template images of various targets, so as to realize the type recognition of each target in the image. This application not only integrates the color, quantity, and type recognition of the target, but also uses less resources than the traditional neural network target recognition algorithm, can run on the FPGA development board, and is suitable for various simple scenes to be used.
附图说明Description of drawings
包括附图以提供对实施例的进一步理解并且附图被并入本说明书中并且构成本说明书的一部分。附图图示了实施例并且与描述一起用于解释本申请的原理。将容易认识到其它实施例和实施例的很多预期优点,因为通过引用以下详细描述,它们变得被更好地理解。附图的元件不一定是相互按照比例的。同样的附图标记指代对应的类似部件。The accompanying drawings are included to provide a further understanding of the embodiments and are incorporated into and constitute a part of this specification. The drawings illustrate embodiments and together with the description serve to explain the principles of the application. Other embodiments and many of the intended advantages of the embodiments will be readily recognized as they become better understood by reference to the following detailed description. The elements of the drawings are not necessarily to scale to each other. Like reference numerals designate corresponding similar parts.
图1是根据本申请实施例的基于形态学识别模板匹配的目标识别方法流程图;1 is a flowchart of a target recognition method based on morphological recognition template matching according to an embodiment of the present application;
图2是根据本申请一个具体实施例的图像二值化示意图;2 is a schematic diagram of image binarization according to a specific embodiment of the present application;
图3是根据本申请一个具体实施例的通过阈值判断进行目标数量识别示意图;3 is a schematic diagram of identifying the number of targets through threshold judgment according to a specific embodiment of the present application;
图4是根据本申请一个具体实施例的存储在ROM中的二值化模板图像示意图;4 is a schematic diagram of a binarized template image stored in a ROM according to a specific embodiment of the present application;
图5是根据本申请一个具体实施例的模板匹配示意图;5 is a schematic diagram of template matching according to a specific embodiment of the present application;
图6是根据本申请一个具体实施例的实物图像检测示意图;6 is a schematic diagram of physical image detection according to a specific embodiment of the present application;
图7是根据本申请一个具体实施例的目标识别结果图;7 is a target recognition result diagram according to a specific embodiment of the present application;
图8是根据本申请另一个具体实施例的实物图像检测示意图;8 is a schematic diagram of physical image detection according to another specific embodiment of the present application;
图9是根据本申请另一个具体实施例的目标识别结果图;9 is a target recognition result diagram according to another specific embodiment of the present application;
图10是根据本申请一个具体实施例的一个三层卷积神经网络框架图;10 is a three-layer convolutional neural network framework diagram according to a specific embodiment of the present application;
图11是根据本申请一个具体实施例的三层卷积神经网络的资源使用情况图;Fig. 11 is a resource usage diagram of a three-layer convolutional neural network according to a specific embodiment of the present application;
图12是根据本申请实施例的基于形态学识别模板匹配的目标识别装置的结构示意图。FIG. 12 is a schematic structural diagram of a target recognition apparatus based on morphological recognition template matching according to an embodiment of the present application.
附图标记说明:1、图像获取模块;2、颜色识别模块;3、数量识别模块;4、模块匹配模块。Description of reference numerals: 1. Image acquisition module; 2. Color identification module; 3. Quantity identification module; 4. Module matching module.
具体实施方式Detailed ways
下面将详细描述本申请的各个方面的特征和示例性实施例,为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细描述。应理解,此处所描述的具体实施例仅被配置为解释本申请,并不被配置为限定本申请。对于本领域技术人员来说,本申请可以在不需要这些具体细节中的一些细节的情况下实施。下面对实施例的描述仅仅是为了通过示出本申请的示例来提供对本申请更好的理解。The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present application, and are not configured to limit the present application. It will be apparent to those skilled in the art that the present application may be practiced without some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating examples of the present application.
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括......”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any relationship between these entities or operations. any such actual relationship or sequence exists. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element defined by the phrase "comprises..." does not preclude the presence of additional identical elements in the process, method, article, or device that includes the element.
首先需要说明的是,本申请的目标识别方法是基于FPGA芯片为硬件载体实现的。当前FPGA相关的目标识别系统所采用的算法要将颜色、数量、种类信息综合起来是非常少的,多数算法只是在做物体位置跟踪和种类识别,因此本申请旨在于利用FPGA作为硬件载体,采用传统的目标识别方法,在资源使用较少的条件下,将目标的颜色、数量、种类识别综合为一体,适用于一些简单的使用场景,从而拓宽FPGA的应用场景。First of all, it should be noted that the target identification method of the present application is implemented based on an FPGA chip as a hardware carrier. The algorithms used by the current FPGA-related target recognition systems need to integrate color, quantity, and type information. Most of the algorithms are only doing object position tracking and type recognition. Therefore, the purpose of this application is to use FPGA as a hardware carrier. The traditional target recognition method integrates the color, quantity, and type recognition of the target under the condition of less resource usage, which is suitable for some simple usage scenarios, thus broadening the application scenarios of FPGA.
根据本申请的第一方面,提出了一种基于形态学识别模板匹配的目标识别方法。图1示出了根据本申请实施例的基于形态学识别模板匹配的目标识别方法流程图,如图1所示,该方法包括以下步骤:According to the first aspect of the present application, a target recognition method based on morphological recognition template matching is proposed. FIG. 1 shows a flowchart of a target recognition method based on morphological recognition template matching according to an embodiment of the present application. As shown in FIG. 1 , the method includes the following steps:
S1、获取原始图像。S1. Obtain an original image.
在具体的实施例中,利用ALINX的5640摄像头采集原始图像,通过DDR3将图像存储。In a specific embodiment, the 5640 camera of ALINX is used to collect the original image, and the image is stored through DDR3.
S2、将原始图像从RGB格式转为YCBCR格式,并对转格式后的原始图像进行二值化处理,得到二值化图像,根据各种颜色所对应的YCBCR的第一阈值,从二值化图像中依次筛选出大于对应第一阈值的像素点。S2. Convert the original image from RGB format to YCBCR format, and perform binarization processing on the converted original image to obtain a binarized image. According to the first threshold of YCBCR corresponding to each color, from binarization Pixels larger than the corresponding first threshold are screened out in sequence in the image.
在具体的实施例中,在获取到原始图像后,便将数据导入到FPGA开发板上进行处理。原始图像从RGB格式转为YCBCR格式的公式具体为:In a specific embodiment, after the original image is acquired, the data is imported into the FPGA development board for processing. The formula for converting the original image from RGB format to YCBCR format is as follows:
Y=0.183R+0.614G+0.062B+16Y=0.183R+0.614G+0.062B+16
CB=-0.101R-0.338G+0.439B+128CB=-0.101R-0.338G+0.439B+128
CR=0.439R-0.399G-0.040B+128CR=0.439R-0.399G-0.040B+128
对图像进行二值化处理可以更好的分辨图像中的像素点和背景点,使图像变得简单,更能凸显出目标的轮廓。以识别水果为例,识别水果的颜色主要目的就是寻找红色、黄色、绿色、紫色、棕褐色等这些常见的水果颜色,本实施例中采用MATLAB进行图像处理,确定出了每种颜色对应的YCBCR的第一阈值,为了防止这些颜色的第一阈值之间存在干扰,可以不断的完善的第一阈值,使第一阈值在一个范围内。在确定了每种颜色对应的YCBCR的第一阈值后,通过比较大小的方式,从二值化图像从上到下、从左到右的顺序,依次筛选出二值化图像中大于对应第一阈值的像素点,从而识别出这些像素点的颜色。图2示出了根据本申请一个具体实施例的图像二值化示意图。Binarizing the image can better distinguish the pixels and background points in the image, making the image simpler and more able to highlight the outline of the target. Taking fruit identification as an example, the main purpose of identifying fruit colors is to find common fruit colors such as red, yellow, green, purple, tan, etc. In this embodiment, MATLAB is used for image processing, and the YCBCR corresponding to each color is determined. In order to prevent interference between the first thresholds of these colors, the first thresholds can be continuously improved so that the first thresholds are within a range. After determining the first threshold of YCBCR corresponding to each color, by comparing the size, from the top to bottom and left to right of the binarized image, filter out the binarized image that is larger than the corresponding first threshold. Threshold pixels to identify the color of these pixels. FIG. 2 shows a schematic diagram of image binarization according to a specific embodiment of the present application.
在具体的实施例中,每进行一次像素点与对应第一阈值的比较后,都会对应的生成一个使能信号,例如,像素点的YCBCR值大于等于对应的第一阈值,则使能信号为1,像素点的YCBCR值小于对应的第一阈值,则使能信号为0。In a specific embodiment, each time a pixel is compared with the corresponding first threshold, an enable signal will be generated correspondingly. For example, if the YCBCR value of the pixel is greater than or equal to the corresponding first threshold, the enable signal is 1. If the YCBCR value of the pixel is less than the corresponding first threshold, the enable signal is 0.
S3、判断两个像素点之间的距离是否大于第二阈值,若是,则两个像素点对应不同的目标,若否,则两个像素点为同一个目标,并生成新的第二阈值。S3. Determine whether the distance between the two pixels is greater than the second threshold. If so, the two pixels correspond to different targets. If not, the two pixels are the same target, and a new second threshold is generated.
在具体的实施例中,步骤S2所筛选出的像素点可能都一一对应一个目标,也有可能2个或2个以上的像素点对应同一个目标,因此通过判断新的像素点与旧的像素点之间的距离是否大于第二阈值,若大于第二阈值,则判断该新的像素点对应一个新目标,若小于第二阈值,则判断该新的像素点与旧的像素点对应同一个目标。以下将以具体的实施例来解释这一部分的内容。In a specific embodiment, the pixels selected in step S2 may all correspond to one target, or two or more pixels may correspond to the same target, so by judging the new pixel and the old pixel Whether the distance between the points is greater than the second threshold, if it is greater than the second threshold, it is judged that the new pixel corresponds to a new target, if it is less than the second threshold, it is judged that the new pixel corresponds to the same one as the old pixel Target. The following will explain the content of this part with specific embodiments.
首先,先按顺序初始化多个候选框,候选框的数量可以自行设定,这些候选框的初始横纵坐标都为(0,0)。在步骤S2筛选出第一个像素点时,根据对应的使能信号对第一个候选框进行赋值,从而在二值化图像的该像素点位置上框选出带有相应颜色的检测框。检测框是通过行场定位扫描生成的,其生成过程具体为:以行左边框和场左边框为左上边框点,扫描生成500*500像素值大小的检测框,以使对应的像素点落在检测框的中心。First, initialize multiple candidate frames in order, the number of candidate frames can be set by yourself, and the initial horizontal and vertical coordinates of these candidate frames are (0, 0). When the first pixel is screened out in step S2, the first candidate frame is assigned a value according to the corresponding enable signal, so that a detection frame with a corresponding color is framed at the pixel position of the binarized image. The detection frame is generated by line and field positioning scanning. The specific generation process is as follows: take the left border of the line and the left border of the field as the upper left border point, and scan to generate a detection frame with a size of 500*500 pixels, so that the corresponding pixel points fall on the upper left border. The center of the detection box.
当步骤S2再次筛选出新的像素点时,首先判断这个新的像素点是否在旧的像素点所在的检测框内(即判断新的像素点和旧的像素点之间的距离是否小于检测框的半边长250像素),若是,可以判断新的像素点和旧的像素点属于同一个目标,那么此时将这个新的像素点作为旧的像素点对应的检测框的边界,这样一来,旧的像素点的检测框便得到缩小,从而可以更为精准的框选出二值化图像中的目标;若否,则判断新的像素点对应一个新目标,此时再次根据对应的使能信号对下一个(即第二个)候选框进行赋值,从而在二值化图像对应新的像素点位置上框选出带有相应颜色的检测框。以此类推,直至完成对所有像素点的判断。因此,不难理解的是,第二阈值是会根据判断结果而不断新增的,第二阈值相当于每个带有检测框的像素点与其检测框上下左右边界之间的距离。When a new pixel is screened out again in step S2, first determine whether the new pixel is in the detection frame where the old pixel is located (that is, determine whether the distance between the new pixel and the old pixel is smaller than the detection frame). The half-side length is 250 pixels), if it is, it can be judged that the new pixel and the old pixel belong to the same target, then this new pixel is used as the boundary of the detection frame corresponding to the old pixel. In this way, The detection frame of the old pixel point is reduced, so that the target in the binarized image can be selected more accurately; if not, it is judged that the new pixel point corresponds to a new target, and then again according to the corresponding enable The signal assigns a value to the next (that is, the second) candidate frame, so as to select a detection frame with a corresponding color at the position of the new pixel point in the binarized image. And so on, until the judgment of all pixels is completed. Therefore, it is not difficult to understand that the second threshold value will be continuously added according to the judgment result, and the second threshold value is equivalent to the distance between each pixel point with a detection frame and the upper, lower, left, and right boundaries of the detection frame.
图3示出了根据本申请一个具体实施例的通过阈值判断进行目标数量识别示意图,如图3(a)所示,第一个像素点(左边)和第二个像素点(右边)之间的距离大于第二阈值,因此两个像素点对应两个目标并均显示有检测框;如图3(b)所示,第一个像素点(左边)和第二个像素点(右边)之间的距离大于第二阈值,虽然两个像素点的检测框有重叠的部分,但仍判断对应不同的目标;如图3(c)所示,第一个像素点(右边)和第二个像素点(左边)之间的距离大于第二阈值,第二个像素点落在第一个像素点的检测框内,因此两个像素点对应同一个目标,将第二个像素点作为第一个像素点的检测框的左边边界,第一个像素点的检测框缩小。Fig. 3 shows a schematic diagram of identifying the number of targets through threshold judgment according to a specific embodiment of the present application. As shown in Fig. 3(a), between the first pixel point (left side) and the second pixel point (right side) The distance between the two pixels is greater than the second threshold, so the two pixels correspond to two targets and both display a detection frame; as shown in Figure 3(b), the difference between the first pixel (left) and the second pixel (right) is The distance between the two pixels is greater than the second threshold. Although the detection frames of the two pixels have overlapping parts, they are still judged to correspond to different targets; as shown in Figure 3(c), the first pixel (right) and the second pixel The distance between the pixels (left) is greater than the second threshold, and the second pixel falls within the detection frame of the first pixel, so the two pixels correspond to the same target, and the second pixel is used as the first pixel. The left border of the detection frame of each pixel, and the detection frame of the first pixel is reduced.
S4、将二值化图像与各种目标的二值化模板图像进行匹配,从而确定二值化图像中存在的各个目标对应的类型。S4: Match the binarized image with the binarized template images of various targets, so as to determine the type corresponding to each target existing in the binarized image.
在具体的实施例中,针对水果的种类识别,为了节省片内资源,提升识别速度,在综合考虑了所需识别目标的特征后决定采取形态学识别的方法。简而言之,就是先识别可以通过颜色来区分的水果类别,比如水果中苹果、猕猴桃、火龙果等颜色比较独特的水果种类可以由颜色进行判断,对于相同颜色的比如香蕉和芒果,采取的是模板匹配的方法进行判断。所谓模板匹配就是在FPGA中用ROM分别存储香蕉、芒果等各种目标的二值化模板图像,当摄像头拍摄到香蕉或者芒果后,根据步骤S3中判断得到的各个目标,将二值化图像分割成对应各个目标的目标图像,且目标图像与各种目标的二值化模板图像大小相同,将目标图像与各种目标的二值化模板图像进行匹配,最终统计匹配的结果,得分高的即为对应的种类,这种方法可以应用在其它具有相同颜色但是种类不同的水果识别中。In a specific embodiment, for the type recognition of fruits, in order to save on-chip resources and improve the recognition speed, it is decided to adopt the morphological recognition method after comprehensively considering the characteristics of the target to be recognized. In short, it is to first identify the fruit categories that can be distinguished by color, such as apples, kiwi fruit, dragon fruit and other fruits with unique colors, which can be judged by color. For the same color, such as bananas and mangoes, take the It is the method of template matching to judge. The so-called template matching is to store the binarized template images of various targets such as bananas and mangoes in the FPGA respectively. After the camera captures the bananas or mangoes, the binarized images are segmented according to each target determined in step S3. A target image corresponding to each target, and the target image is the same size as the binarized template image of various targets, the target image is matched with the binary template image of various targets, and the final matching result is counted. The highest score is the For the corresponding species, this method can be applied to the recognition of other fruits with the same color but different species.
图4示出了根据本申请一个具体实施例的存储在ROM中的二值化模板图像示意图,如图4所示,存储的是芒果和香蕉的二值化模板图像。图5示出了根据本申请一个具体实施例的模板匹配示意图,如图5所示,左一是模板信息,右边两幅是采集到的图像信息,将采集到的图像信息与模板信息进行与操作,统计1的个数,显然中间这幅图的匹配程度最高。FIG. 4 shows a schematic diagram of a binarized template image stored in a ROM according to a specific embodiment of the present application. As shown in FIG. 4 , the binarized template images of mango and banana are stored. FIG. 5 shows a schematic diagram of template matching according to a specific embodiment of the present application. As shown in FIG. 5 , the one on the left is template information, and the two on the right are collected image information. The collected image information and template information are combined with each other. Operation, count the number of 1, obviously the middle picture has the highest matching degree.
为了验证本申请目标识别算法的可靠性,本申请还进行了以下目标识别检测实验。In order to verify the reliability of the target recognition algorithm of the present application, the present application also conducts the following target recognition detection experiments.
图6示出了根据本申请一个具体实施例的实物图像检测示意图,图7示出了根据本申请一个具体实施例的目标识别结果图,如图6、图7所示,图6中有3个绿色葡萄,图7中的第一列数据是颜色识别结果,第二列数据是种类识别结果,第三列数据是数量识别结果,根据最新一帧图像的检测结果数据显示,检测到的颜色为GREEN(绿色),种类为grape(葡萄),数量为3。Fig. 6 shows a schematic diagram of physical image detection according to a specific embodiment of the present application, and Fig. 7 shows a target recognition result graph according to a specific embodiment of the present application. As shown in Fig. 6 and Fig. 7, there are 3 The first column of data in Figure 7 is the color recognition result, the second column of data is the type recognition result, and the third column of data is the quantity recognition result. According to the detection result data of the latest frame image, the detected color It is GREEN (green), the type is grape (grape), and the number is 3.
图8示出了根据本申请另一个具体实施例的实物图像检测示意图,图9示出了根据本申请另一个具体实施例的目标识别结果图,如图8、图9所示,图8中有1个黄色香蕉,根据最新一帧图像的检测结果数据显示,检测到的颜色为YELLOW(黄色),种类为banana(葡萄),数量为1。FIG. 8 shows a schematic diagram of physical image detection according to another specific embodiment of the present application, and FIG. 9 shows a target recognition result graph according to another specific embodiment of the present application. As shown in FIGS. 8 and 9 , in FIG. 8 There is 1 yellow banana. According to the detection result data of the latest frame image, the detected color is YELLOW (yellow), the type is banana (grape), and the quantity is 1.
从上述检测结果可知,本申请的目标识别方法具有可靠性。并且需要说明的是,在图7和图9中的第三列数据中,某些帧图像的数量识别结果显示“>”、“<”或“=”,这是因为摄像机在移动拍摄图像时,某些帧无法较好的捕获到目标,从而无法识别出具体的数量。It can be seen from the above detection results that the target recognition method of the present application is reliable. And it should be noted that in the third column of data in Figure 7 and Figure 9, the number recognition results of some frame images display ">", "<" or "=", this is because the camera is moving when the image is captured. , some frames cannot capture the target well, so the specific quantity cannot be identified.
在本实施例中,还给出了本申请的目标识别方法与现有技术基于神经网络的目标识别算法的资源使用情况对比。本实施例中,基于紫光同创PGL22G开发板的片内资源仅有22K。图10示出了根据本申请一个具体实施例的一个三层卷积神经网络框架图,图11示出了根据本申请一个具体实施例的三层卷积神经网络的资源使用情况图,如图10、图11所示,对于一个三层的卷积神经网络来说,实现这三层的神经网络时所消耗的FPGA资源比例是巨大的,况且这是采用计算资源较大的ZYNQ开发板,并不是仅用FPGA来实现,且使用资源占比也较高。In this embodiment, a comparison of resource usage between the target recognition method of the present application and the target recognition algorithm based on neural network in the prior art is also given. In this embodiment, the on-chip resources based on the Tsinghua Unigroup PGL22G development board are only 22K. Fig. 10 shows a framework diagram of a three-layer convolutional neural network according to a specific embodiment of the present application, and Fig. 11 shows a resource usage diagram of a three-layer convolutional neural network according to a specific embodiment of the present application, as shown in Fig. 10. As shown in Figure 11, for a three-layer convolutional neural network, the proportion of FPGA resources consumed when implementing these three-layer neural networks is huge, and this is a ZYNQ development board with large computing resources. It is not only implemented with FPGA, and the proportion of resources used is also high.
综上所述,本申请提出了一种基于形态学识别模板匹配的目标识别方法,先对图像进行RGB转YCBCR格式处理以及二值化处理,然后对每种颜色对应的YCBCR阈值进行分割,从而筛选出图像中对应各种颜色的像素点,实现颜色识别;筛选出像素点后,通过判断两个像素点之间的距离是否大于阈值,从而可以判断新的像素点是否为新的目标,实现数量识别;最后将判断得到的各个目标的目标图像与预先放入的各种目标的二值化模板图像进行一一匹配,从而实现图像中各个目标的种类识别。本申请不仅做到将目标的颜色、数量、种类识别综合为一体,并且相比于传统的神经网络目标识别算法,其资源使用较小,可在FPGA开发板上运行,适用于各种简单的使用场景。To sum up, this application proposes a target recognition method based on morphological recognition template matching. First, the image is processed in RGB to YCBCR format and binarized, and then the YCBCR threshold corresponding to each color is segmented, thereby Screen out the pixels corresponding to various colors in the image to realize color recognition; after screening out the pixels, by judging whether the distance between the two pixels is greater than the threshold, it can be judged whether the new pixel is a new target. Quantity identification; finally, the target image of each target obtained by judgment is matched with the binarized template images of various targets put in in advance, so as to realize the type recognition of each target in the image. This application not only integrates the color, quantity, and type recognition of the target, but also uses less resources than the traditional neural network target recognition algorithm, can run on the FPGA development board, and is suitable for various simple scenes to be used.
根据本申请的第二方面,提出了一种基于形态学识别模板匹配的目标识别装置,该目标识别装置是基于上述的目标识别方法搭建的。图12示出了根据本申请实施例的基于形态学识别模板匹配的目标识别装置的结构示意图,如图12所示,该装置包括:According to the second aspect of the present application, a target recognition device based on morphological recognition template matching is proposed, and the target recognition device is constructed based on the above target recognition method. FIG. 12 shows a schematic structural diagram of a target recognition device based on morphological recognition template matching according to an embodiment of the present application. As shown in FIG. 12 , the device includes:
图像获取模块1,配置用于获取原始图像。The
颜色识别模块2,配置用于将原始图像从RGB格式转为YCBCR格式,并对转格式后的原始图像进行二值化处理,得到二值化图像,根据各种颜色所对应的YCBCR的第一阈值,从二值化图像中依次筛选出大于对应第一阈值的像素点。The
数量识别模块3,配置用于判断两个像素点之间的距离是否大于第二阈值,若是,则两个像素点对应不同的目标,若否,则两个像素点为同一个目标,并生成新的第二阈值。
模板匹配模块4,配置用于将二值化图像与各种目标的二值化模板图像进行匹配,从而确定二值化图像中存在的各个目标对应的类型。The
在具体的实施例中,颜色识别模块2设置有多个,每个颜色识别模块2中保存有一种颜色所对应的YCBCR的第一阈值数据,从而每个颜色识别模块2可以对应筛选一种颜色的像素点。In a specific embodiment, a plurality of
根据本申请的第三方面,提出了一种计算机可读储存介质,其储存有计算机程序,该计算机程序在被处理器执行时实施如本申请第一方面的基于形态学识别模板匹配的目标识别方法。According to a third aspect of the present application, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the target recognition based on morphological recognition template matching according to the first aspect of the present application method.
在本申请实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置/系统/方法实施例仅仅是示意性的,例如所述单元的划分,可以为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the embodiments of the present application, it should be understood that the disclosed technical content may be implemented in other manners. The apparatus/system/method embodiments described above are only illustrative, for example, the division of the units may be a logical function division, and in actual implementation, there may be other divisions, such as multiple units or components May be combined or may be integrated into another system, or some features may be omitted, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of units or modules, and may be in electrical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes .
显然,本领域技术人员在不偏离本申请的精神和范围的情况下可以作出对本申请的实施例的各种修改和改变。以该方式,如果这些修改和改变处于本申请的权利要求及其等同形式的范围内,则本申请还旨在涵盖这些修改和改变。词语“包括”不排除未在权利要求中列出的其它元件或步骤的存在。某些措施记载在相互不同的从属权利要求中的简单事实不表明这些措施的组合不能被用于获利。权利要求中的任何附图标记不应当被认为限制范围。It will be apparent to those skilled in the art that various modifications and changes to the embodiments of the present application can be made without departing from the spirit and scope of the present application. In this manner, this application is also intended to cover such modifications and changes if they come within the scope of the claims of this application and their equivalents. The word "comprising" does not exclude the presence of other elements or steps not listed in a claim. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage. Any reference signs in the claims should not be construed as limiting the scope.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210850252.8A CN115131582A (en) | 2022-07-19 | 2022-07-19 | Target recognition method, device and medium based on morphological recognition template matching |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210850252.8A CN115131582A (en) | 2022-07-19 | 2022-07-19 | Target recognition method, device and medium based on morphological recognition template matching |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN115131582A true CN115131582A (en) | 2022-09-30 |
Family
ID=83384171
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210850252.8A Pending CN115131582A (en) | 2022-07-19 | 2022-07-19 | Target recognition method, device and medium based on morphological recognition template matching |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN115131582A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118654573A (en) * | 2024-08-20 | 2024-09-17 | 山东农业大学 | A method for measuring the appearance and dimensions of sweet cherries based on image recognition |
-
2022
- 2022-07-19 CN CN202210850252.8A patent/CN115131582A/en active Pending
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118654573A (en) * | 2024-08-20 | 2024-09-17 | 山东农业大学 | A method for measuring the appearance and dimensions of sweet cherries based on image recognition |
| CN118654573B (en) * | 2024-08-20 | 2025-02-25 | 山东农业大学 | A method for measuring the appearance and dimensions of sweet cherries based on image recognition |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN112381775B (en) | Image tampering detection method, terminal device and storage medium | |
| CN111488756B (en) | Face recognition-based living body detection method, electronic device, and storage medium | |
| CN111797653B (en) | Image labeling method and device based on high-dimensional image | |
| Murtaza et al. | Multi‐view human action recognition using 2D motion templates based on MHIs and their HOG description | |
| CN107665324B (en) | Image identification method and terminal | |
| AU2017372905A1 (en) | System and method for appearance search | |
| US20160307057A1 (en) | Fully Automatic Tattoo Image Processing And Retrieval | |
| CN112686248B (en) | Method, device, readable storage medium, and terminal for detecting increase or decrease of certificate types | |
| WO2017181892A1 (en) | Foreground segmentation method and device | |
| JP2003016448A (en) | Event clustering of images using foreground/background segmentation | |
| CN105868708A (en) | Image object identifying method and apparatus | |
| Wang et al. | A real-time multi-face detection system implemented on FPGA | |
| CN112784932B (en) | Font identification method, device and storage medium | |
| US20220414393A1 (en) | Methods and Systems for Generating Composite Image Descriptors | |
| CN111028263B (en) | Moving object segmentation method and system based on optical flow color clustering | |
| US12073602B2 (en) | Automated key frame selection | |
| CN109934216A (en) | Image processing method, apparatus, and computer-readable storage medium | |
| WO2018179361A1 (en) | Image-processing device, image-processing method, and recording medium | |
| CN114596242A (en) | Defect detection method, apparatus, electronic device, and computer-readable storage medium | |
| CN119131364B (en) | Unmanned aerial vehicle small target detection method based on unsupervised countermeasure learning | |
| CN108846364B (en) | FPGA-based video feature detection method and system | |
| CN107622280A (en) | Scene classification based image saliency detection method based on modular prescription | |
| CN112052730B (en) | 3D dynamic portrait identification monitoring equipment and method | |
| CN109977875A (en) | Gesture identification method and equipment based on deep learning | |
| CN118657736A (en) | A drip detection method, product and device based on differential background modeling |
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 |