TW202111598A - Method and device for positioning target object in image, computer device and storage medium - Google Patents
Method and device for positioning target object in image, computer device and storage medium Download PDFInfo
- Publication number
- TW202111598A TW202111598A TW108131958A TW108131958A TW202111598A TW 202111598 A TW202111598 A TW 202111598A TW 108131958 A TW108131958 A TW 108131958A TW 108131958 A TW108131958 A TW 108131958A TW 202111598 A TW202111598 A TW 202111598A
- Authority
- TW
- Taiwan
- Prior art keywords
- area
- target area
- target
- image
- pixels
- Prior art date
Links
Images
Landscapes
- Image Analysis (AREA)
Abstract
Description
本發明涉及圖像中目標物體定位領域, 具體涉及一種圖像中目標物體定位方法、圖像中目標物體定位裝置、電腦裝置及電腦存儲介質。The present invention relates to the field of locating target objects in images, in particular to a method for locating target objects in images, a device for locating target objects in images, computer devices and computer storage media.
隨著圖像識別技術之發展,圖像識別技術已經應用到生產生活之各個方面。例如攝像設備可以在拍照之時候自動識別並精確定位人臉之位置。為了得到更好之識別效果,攝像設備需要在出廠前對所要識別物件之定位能力進行校正,現有之生產過程中,往往是通過人工標定之方式對攝像設備所要識別物件進行定位,通過人工定位之方法準確率低,速度慢。With the development of image recognition technology, image recognition technology has been applied to all aspects of production and life. For example, the camera equipment can automatically recognize and accurately locate the position of a human face when taking a picture. In order to get a better recognition effect, the camera equipment needs to calibrate the positioning ability of the object to be recognized before leaving the factory. In the existing production process, the object to be recognized by the camera equipment is often positioned by manual calibration. The method has low accuracy and slow speed.
鑒於以上內容,有必要提出一種圖像中目標物體定位方法及裝置、電腦裝置和電腦可讀存儲介質,使得對圖像中目標物體之定位以更加智慧快捷之方式進行。In view of the above, it is necessary to provide a method and device for locating a target object in an image, a computer device, and a computer-readable storage medium, so that the locating of the target object in the image can be performed in a smarter and faster way.
本申請之第一方面提供一種圖像中目標物體定位方法,所述方法包括: 獲取待識別圖像; 識別所述待識別圖像中至少一個目標區域,並對所述目標區域進行標記,得到至少一個標記區域,其中,所述標記區域之面積大於或等於所述目標區域之面積,且所述目標區域位於所述標記區域內; 對所述標記區域進行二值化處理,其中所述經過二值化處理後之目標區域之畫素點之顏色和目標區域外之畫素點之顏色不同; 在所述標記區域中識別所述目標區域之邊界畫素以及目標區域內之有效畫素; 通過所述邊界畫素和有效畫素之位置確定並輸出所述目標區域之中心和大小。The first aspect of the present application provides a method for locating a target object in an image, and the method includes: Obtain the image to be recognized; Identify at least one target area in the image to be recognized, and mark the target area to obtain at least one marked area, wherein the area of the marked area is greater than or equal to the area of the target area, and the target The area is located in the marked area; Binarize the marked area, wherein the color of the pixel points in the target area after the binarization process is different from the color of the pixel points outside the target area; Identifying boundary pixels of the target area and valid pixels in the target area in the marked area; Determine and output the center and size of the target area through the positions of the boundary pixels and effective pixels.
優選地,識別所述待識別圖像中至少一個目標區域之步驟包括: 獲取所待識別之目標區域之特徵資訊; 在所述待識別圖像中查找是否存在所述特徵資訊; 若存在所述特徵資訊,則確定具有所述特徵資訊之區域為目標區域; 若不存在所述特徵資訊,則發出提示消息提示不存在目標區域。Preferably, the step of identifying at least one target area in the image to be identified includes: Obtain the characteristic information of the target area to be identified; Searching for the feature information in the image to be recognized; If the characteristic information exists, determine the area with the characteristic information as the target area; If the feature information does not exist, a prompt message is issued to prompt that there is no target area.
優選地,在所述標記區域中識別所述目標區域之邊界畫素之步驟包括: 在標記區域中識別目標區域中每一畫素點之顏色; 判斷所述目標區域中每一畫素點相鄰之其他八個畫素點之顏色; 若所述目標區域畫素點周圍之八個畫素點中同時存在與所述目標區域畫素點顏色一致和不一致之畫素點,則所述目標區域畫素點為邊界畫素。Preferably, the step of identifying boundary pixels of the target area in the marking area includes: Identify the color of each pixel in the target area in the marked area; Judging the colors of the other eight pixel points adjacent to each pixel point in the target area; If the eight pixel points around the target area pixel points have pixel points that are consistent and inconsistent in color with the target area pixel points at the same time, then the target area pixel points are boundary pixels.
優選地,在所述標記區域中識別所述目標區域之邊界畫素之步驟還包括: 在標記區域中查找除所述邊界畫素以外之待標定畫素; 判斷所述待標定畫素之水準和豎直方向是否存在邊界畫素; 若所述待標定畫素之水準和豎直方向同時存在邊界畫素,則所述待標定畫素為有效畫素。Preferably, the step of identifying boundary pixels of the target area in the marking area further includes: Searching for pixels to be calibrated other than the boundary pixels in the marked area; Judging whether there are boundary pixels in the level and vertical direction of the pixels to be calibrated; If there are boundary pixels in both the horizontal and vertical directions of the pixel to be calibrated, the pixel to be calibrated is a valid pixel.
優選地,通過所述邊界畫素和有效畫素之位置確定並輸出所述目標區域之中心和大小之方法包括: 根據有效畫素之位置將所述標記區域中之所有之邊界畫素進行連線得到所述目標區域之形狀; 根據所述目標區域之形狀計算所述目標區域之大小及中心。Preferably, the method of determining and outputting the center and size of the target area through the positions of the boundary pixels and effective pixels includes: Connect all the boundary pixels in the marked area according to the positions of the effective pixels to obtain the shape of the target area; Calculate the size and center of the target area according to the shape of the target area.
本申請之第二方面提供一種圖像中目標物體定位裝置,所述裝置包括: 獲取模組,用於獲取待識別圖像; 標識模組,用於識別所述待識別圖像中至少一個目標區域,並對所述目標區域進行標記,得到至少一個標記區域,其中,所述標記區域之面積大於或等於所述目標區域之面積,且所述目標區域位於所述標記區域內; 處理模組,用於對所述標記區域進行二值化處理,其中所述經過二值化處理後之目標區域之畫素點之顏色和目標區域外之畫素點之顏色不同; 查找模組,用於在所述標記區域中識別所述目標區域之邊界畫素以及目標區域內之有效畫素; 輸出模組,用於通過所述邊界畫素和有效畫素之位置確定並輸出所述目標區域之中心和大小。A second aspect of the present application provides a device for locating a target object in an image, the device comprising: The acquisition module is used to acquire the image to be recognized; The identification module is used to identify at least one target area in the image to be recognized, and mark the target area to obtain at least one marked area, wherein the area of the marked area is greater than or equal to that of the target area Area, and the target area is located in the marked area; A processing module for binarizing the marked area, wherein the color of the pixel points in the target area after the binarization process is different from the color of the pixel points outside the target area; The search module is used to identify the boundary pixels of the target area and the effective pixels in the target area in the marked area; The output module is used to determine and output the center and size of the target area through the positions of the boundary pixels and effective pixels.
本申請之協力廠商面提供一種電腦裝置,所述電腦裝置包括處理器,所述處理器用於執行記憶體中存儲之電腦程式時實現如前所述圖像中目標物體定位方法。The third party of this application provides a computer device, the computer device includes a processor, and the processor is used to implement the aforementioned method for locating a target object in an image when executing a computer program stored in a memory.
本申請之第四方面提供一種電腦存儲介質,其上存儲有電腦程式,所述電腦程式被處理器執行時實現如前所述圖像中目標物體定位方法。The fourth aspect of the present application provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method for locating a target object in an image as described above is realized.
本發明圖像中目標物體定位方法通過對圖像中目標區域畫素及目標區域周邊畫素之顏色進行判斷,通過目標區域畫素及目標區域周邊畫素之位置確定目標區域之形狀和大小。通過所述方法可以使圖像中目標物體之識別更加準確和快捷。The method for locating the target object in the image of the present invention judges the color of the target area pixels and the surrounding pixels in the image, and determines the shape and size of the target area by the positions of the target area pixels and the surrounding pixels of the target area. The method can make the recognition of the target object in the image more accurate and faster.
為了能夠更清楚地理解本發明之上述目之、特徵和優點,下面結合附圖和具體實施例對本發明進行詳細描述。需要說明之是,在不衝突之情況下,本申請之實施例及實施例中之特徵可以相互組合。In order to be able to understand the above objectives, features and advantages of the present invention more clearly, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the application and the features in the embodiments can be combined with each other if there is no conflict.
在下面之描述中闡述了很多具體細節以便於充分理解本發明,所描述之實施例僅僅是本發明一部分實施例,而不是全部之實施例。基於本發明中之實施例,本領域普通技術人員在沒有做出創造性勞動前提下所獲得之所有其他實施例,都屬於本發明保護之範圍。In the following description, many specific details are explained in order to fully understand the present invention. The described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
除非另有定義,本文所使用之所有之技術和科學術語與屬於本發明之技術領域之技術人員通常理解之含義相同。本文中在本發明之說明書中所使用之術語只是為了描述具體之實施例之目之,不是旨在於限制本發明。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments, and are not intended to limit the present invention.
實施例一 請參閱圖1所示,是本發明第一實施例提供之圖像中目標物體定位方法之流程圖。根據不同之需求,所述流程圖中步驟之順序可以改變,某些步驟可以省略。Example one Please refer to FIG. 1, which is a flowchart of a method for locating a target object in an image provided by the first embodiment of the present invention. According to different needs, the order of the steps in the flowchart can be changed, and some steps can be omitted.
步驟S1、獲取待識別圖像。Step S1: Obtain an image to be recognized.
在本發明一實施方式,通過攝像設備中之處理器獲取攝感光元件採集之待識別圖像之圖像資訊。在其他實施方式中,也可以從其他存儲介質中獲取待識別圖像。In one embodiment of the present invention, the image information of the image to be recognized collected by the photosensitive element is obtained by the processor in the imaging device. In other embodiments, the image to be recognized can also be obtained from other storage media.
步驟S2、識別所述待識別圖像中至少一個目標區域,並對所述目標區域進行標記,得到至少一個標記區域,其中,所述標記區域之面積大於或等於所述目標區域之面積,且所述目標區域位於所述標記區域內。Step S2. Identify at least one target area in the image to be recognized, and mark the target area to obtain at least one marked area, wherein the area of the marked area is greater than or equal to the area of the target area, and The target area is located in the marked area.
在本發明一實施方式中,識別所述待識別圖像中至少一個目標區域之步驟可以包括: 獲取所待識別之目標區域之特徵資訊; 在所述待識別圖像中查找是否存在所述特徵資訊; 若存在所述特徵資訊,則標記具有所述特徵資訊之區域; 若不存在所述特徵資訊,則發出提示消息。In an embodiment of the present invention, the step of identifying at least one target area in the image to be identified may include: Obtain the characteristic information of the target area to be identified; Searching for the feature information in the image to be recognized; If the feature information exists, mark the area with the feature information; If the feature information does not exist, a prompt message is issued.
舉例而言,請參閱圖2 是本發明實施例一提供之圖像中目標物體定位方法標定區域示意圖。攝像設備中之處理器獲取所述待識別圖像之圖像資訊,從資料中獲取所要識別之目標區域之特徵資訊,所述資料庫中存儲了所要識別之目標區域之歷史特徵資訊,處理器在所述待識別圖像中查找具有所述特徵資訊之目標區域,在所述待識別圖像中處理器經過和資料庫中之特徵資訊進行匹配查找,標記出包含所述目標區域之標記區域,如圖2中七個小方框所示。圖2 中標記了7個標記區域,每個所述標記區域中包含有一個完整之目標區域,且標記區域之面積大於目標區域之面積,在圖2中所示之七個標記區域中,由於有之相鄰目標區域之間之間隔很近,在一些標記區域中不僅包含了一個完整之目標區域,還包括了部分與所述完整之目標區域相鄰之其他目標區域。在本發明之其他實施方式中,所述標記區域之面積也可以等於目標區域之面積,且目標區域處於標記區域中;所述標記區域之形狀也可以是圓形、長方形等其他形狀。For example, please refer to FIG. 2 which is a schematic diagram of the calibration area of the target object positioning method in the image provided by the first embodiment of the present invention. The processor in the imaging device obtains the image information of the image to be recognized, and obtains the characteristic information of the target area to be recognized from the data. The database stores the historical characteristic information of the target area to be recognized, and the processor Search for the target area with the characteristic information in the image to be recognized, and in the image to be recognized, the processor performs matching search with the characteristic information in the database, and marks the marked area containing the target area , As shown in the seven small boxes in Figure 2. 7 marked areas are marked in Figure 2, and each of the marked areas contains a complete target area, and the area of the marked area is larger than the area of the target area. Among the seven marked areas shown in Figure 2, because Some adjacent target areas are closely spaced. In some marked areas, not only a complete target area is included, but also some other target areas adjacent to the complete target area are included. In other embodiments of the present invention, the area of the marking area may also be equal to the area of the target area, and the target area is in the marking area; the shape of the marking area may also be a circle, a rectangle or other shapes.
若處理器在所述待識別圖像中沒有查找出具有所述特徵資訊之區域,則以提示資訊之形式發出未找出所述目標區域之消息。If the processor does not find an area with the characteristic information in the image to be recognized, it sends a message in the form of prompt information that the target area is not found.
步驟S3、對所述標記區域進行二值化處理,其中所述經過二值化處理後之目標區域之畫素點之顏色和目標區域外之畫素點之顏色不同。Step S3: Binarize the marked area, wherein the color of the pixel points in the target area after the binarization process is different from the color of the pixel points outside the target area.
在本發明一實施方式中,請參閱圖3是本發明實施例一提供之圖像中目標物體定位方法標記區域二值化示意圖,對標定區域進行二值化處理之步驟可以為:將識別出得到所述目標區域之畫素點之顏色值賦予255,將識別得到之目標區域外之顏色值賦予0。經過二值化處理之後,如圖3所示,待識別圖像中之七個標記區域中,所述目標區域之畫素點之顏色為黑色,所述目標區域外之畫素點之顏色為白色,圖3中有四個標記區域不僅包含了一個完整之目標區域,還包含了與所述完整之目標區域相鄰之部分其他目標區域,如圖3中所示,所述部分其他目標區域畫素值經過二值化處理之後被賦予為黑色。In an embodiment of the present invention, please refer to FIG. 3 which is a schematic diagram of the binarization of the marked area of the target object positioning method in the image provided in the first embodiment of the present invention. The steps of binarizing the marked area may be: The color value of the pixel point in the target area is assigned 255, and the color value outside the recognized target area is assigned 0. After the binarization process, as shown in Figure 3, among the seven marked areas in the image to be recognized, the color of the pixel points in the target area is black, and the color of the pixel points outside the target area is White, there are four marked areas in Figure 3 that not only contain a complete target area, but also some other target areas adjacent to the complete target area, as shown in Figure 3, the part of other target areas The pixel value is given black after binarization.
步驟S4、在所述標記區域中識別所述目標區域之邊界畫素以及目標區域內之有效畫素。Step S4: Identify boundary pixels of the target area and effective pixels in the target area in the marked area.
在本發明一實施方式中,在所述標記區域中識別所述目標區域之邊界畫素之步驟可以包括: 在標記區域中識別目標區域中每一畫素點之顏色; 並判斷所述目標區域中每一畫素點相鄰之其他八個畫素點之顏色; 若所述目標區域畫素點周圍之八個畫素同時存在與所述目標區域畫素點顏色一致之畫素點和與所述目標區域畫素點顏色不同畫素點,則所述目標區域畫素點為邊界畫素。In an embodiment of the present invention, the step of identifying boundary pixels of the target area in the marked area may include: Identify the color of each pixel in the target area in the marked area; And judging the colors of the other eight pixel points adjacent to each pixel point in the target area; If the eight pixels around the pixel point of the target area simultaneously have pixel points with the same color as the pixel points of the target area and pixel points with different colors from the pixel points of the target area, then the target area The pixel points are boundary pixels.
舉例而言,請參閱圖4 是本發明實施例一提供之圖像中目標物體定位方法目標區域邊界畫素和有效畫素示意圖。對於任意一個標記區域,按照步驟S3賦予之目標區域之顏色值查找所述標記區域中具有目標區域顏色值之畫素點,如圖4所示,目標區域之畫素點為黑色,則在標記區域中查找畫素顏色值為255之畫素點。對於任意一個顏色值為255之畫素點,查找在所述畫素點周圍之其他八個畫素點之顏色,若所述顏色值為255之畫素點周圍之其他八個畫素點同時存在顏色值為0之白色畫素點和顏色值為255之黑色畫素點,則位於所述八個畫素點中心之顏色值為255之畫素點為邊界畫素。並對所述邊界畫素之位置進行標記。For example, please refer to FIG. 4 for a schematic diagram of the boundary pixels and effective pixels of the target area in the method for locating a target object in an image according to the first embodiment of the present invention. For any marked area, according to the color value of the target area given in step S3, search for the pixel point with the color value of the target area in the marked area. As shown in Fig. 4, the pixel point of the target area is black, then the mark Find pixel points with pixel color value of 255 in the area. For any pixel point with a color value of 255, search for the colors of the other eight pixel points around the pixel point. If the color value of the other eight pixel points around the pixel point is 255 at the same time If there is a white pixel point with a color value of 0 and a black pixel point with a color value of 255, the pixel point with a color value of 255 located at the center of the eight pixel points is a boundary pixel. And mark the position of the boundary pixel.
在所述標記區域中識別所述目標區域之邊界畫素之步驟可以包括: 在標記區域中查找除所述邊界畫素以外之待標定畫素; 判斷所述待標定畫素之水準和豎直方向是否存在邊界畫素; 若所述待標定畫素之水準和豎直方向同時存在邊界畫素,則所述待標定畫素為有效畫素。The step of identifying boundary pixels of the target area in the marked area may include: Searching for pixels to be calibrated other than the boundary pixels in the marked area; Judging whether there are boundary pixels in the level and vertical direction of the pixels to be calibrated; If there are boundary pixels in both the horizontal and vertical directions of the pixel to be calibrated, the pixel to be calibrated is a valid pixel.
舉例而言,請參閱圖4 是本發明實施例一提供之圖像中目標物體定位方法目標區域邊界畫素和有效畫素示意圖。在待標記圖像中查找除邊界畫素以外之其他待標定畫素,所述待標定畫素可能是黑色畫素,也可能是白色畫素。對於任意一個待標定畫素,以所述待標定畫素為中心,分別朝水準和豎直方向判斷是否存在邊界畫素,若以所述待標定畫素為中心之水準、豎直四個方向均存在邊界畫素,則所述待標定畫素為有效畫素。For example, please refer to FIG. 4 for a schematic diagram of the boundary pixels and effective pixels of the target area in the method for locating a target object in an image according to the first embodiment of the present invention. Search for other pixels to be calibrated except boundary pixels in the image to be marked. The pixels to be calibrated may be black pixels or white pixels. For any pixel to be calibrated, take the pixel to be calibrated as the center, and judge whether there are boundary pixels in the horizontal and vertical directions respectively. If the pixel to be calibrated is the center of the horizontal and vertical directions If there are boundary pixels, the pixels to be calibrated are valid pixels.
步驟S5、通過所述邊界畫素和有效畫素之位置確定並輸出所述目標區域之中心和大小。Step S5: Determine and output the center and size of the target area through the positions of the boundary pixels and effective pixels.
通過所述邊界畫素和有效畫素之位置確定並輸出所述目標區域之中心和大小之方法可以包括: 按照標記區域中之邊界畫素和有效畫素之位置確定目標區域之形狀; 根據所述目標區域之形狀計算所述目標區域之大小及中心。The method of determining and outputting the center and size of the target area through the positions of the boundary pixels and effective pixels may include: Determine the shape of the target area according to the position of the boundary pixels and the effective pixels in the marked area; Calculate the size and center of the target area according to the shape of the target area.
舉例而言,步驟S4確認之所述邊界畫素和有效畫素之位置,將所述邊界畫素進行連線,得到目標區域之形狀為四邊形,根據四邊形之中心及面積計算公式得到所述目標區域之中心如圖5圖像中目標物體定位方法定位結果示意圖所示。For example, the position of the boundary pixels and the effective pixels confirmed in step S4, the boundary pixels are connected to obtain the shape of the target area as a quadrilateral, and the target is obtained according to the center and area calculation formula of the quadrilateral The center of the area is shown in the schematic diagram of the positioning result of the target object positioning method in the image in Figure 5.
上述圖1詳細介紹了本發明之圖像中目標物體定位方法,下面結合第6-7圖,對實現所述圖像中目標物體定位方法之軟體裝置之功能模組以及實現所述圖像中目標物體定位方法之硬體裝置架構進行介紹。Figure 1 above describes in detail the method for locating a target object in an image of the present invention. In conjunction with Figures 6-7, the functional modules of the software device that implement the method for locating a target object in the image and the realization of the image The hardware device architecture of the target object positioning method is introduced.
應所述瞭解,所述實施例僅為說明之用,在專利申請範圍上並不受此結構之限制。It should be understood that the embodiments are only for illustrative purposes, and are not limited by this structure in the scope of the patent application.
實施例二Example two
圖6為本發明圖像中目標物體定位裝置較佳實施例之結構圖。Fig. 6 is a structural diagram of a preferred embodiment of a device for positioning a target object in an image of the present invention.
在一些實施例中,圖像中目標物體定位裝置10運行於電腦裝置中。所述圖像中目標物體定位裝置10可以包括多個由程式碼段所組成之功能模組。所述圖像中目標物體定位裝置10中之各個程式段之程式碼可以存儲於電腦裝置之記憶體中,並由所述至少一個處理器所執行,以實現圖像中目標物體定位功能。In some embodiments, the
本實施例中,所述圖像中目標物體定位裝置10根據其所執行之功能,可以被劃分為多個功能模組。參閱圖6所示,所述功能模組可以包括:獲取模組101、標識模組102、處理模組103、查找模組104、輸出模組105。本發明所稱之模組是指一種能夠被至少一個處理器所執行並且能夠完成固定功能之一系列電腦程式段,其存儲在記憶體中。在本實施例中,關於各模組之功能將在後續之實施例中詳述。In this embodiment, the
獲取模組101,用於獲取待識別圖像。The obtaining
在本發明一實施方式,通過攝像設備中之處理器獲取攝感光元件採集之待識別圖像之圖像資訊。在其他實施方式中,也可以從其他存儲介質中獲取待識別圖像。In one embodiment of the present invention, the image information of the image to be recognized collected by the photosensitive element is obtained by the processor in the imaging device. In other embodiments, the image to be recognized can also be obtained from other storage media.
標識模組102,用於識別所述待識別圖像中至少一個目標區域,並對所述目標區域進行標記,得到至少一個標記區域,其中,所述標記區域之面積大於或等於所述目標區域之面積,且所述目標區域位於所述標記區域內。The marking
在本發明一實施方式中,識別所述待識別圖像中至少一個目標區域之步驟可以包括: 獲取所待識別之目標區域之特徵資訊; 在所述待識別圖像中查找是否存在所述特徵資訊; 若存在所述特徵資訊,則標記具有所述特徵資訊之區域; 若不存在所述特徵資訊,則發出提示消息。In an embodiment of the present invention, the step of identifying at least one target area in the image to be identified may include: Obtain the characteristic information of the target area to be identified; Searching for the feature information in the image to be recognized; If the feature information exists, mark the area with the feature information; If the feature information does not exist, a prompt message is issued.
舉例而言,請參閱圖2 是本發明實施例一提供之圖像中目標物體定位方法標定區域示意圖。攝像設備中之處理器獲取所述待識別圖像之圖像資訊,從資料中獲取所要識別之目標區域之特徵資訊,所述資料庫中存儲了所要識別之目標區域之歷史特徵資訊,處理器在所述待識別圖像中查找具有所述特徵資訊之目標區域,在所述待識別圖像中處理器經過和資料庫中之特徵資訊進行匹配查找,標記出包含所述目標區域之標記區域,如圖2中七個小方框所示。圖2 中標記了7個標記區域,每個所述標記區域中包含有一個完整之目標區域,且標記區域之面積大於目標區域之面積,在圖2中所示之七個標記區域中,由於有之相鄰目標區域之間之間隔很近,在一些標記區域中不僅包含了一個完整之目標區域,還包括了部分與所述完整之目標區域相鄰之其他目標區域。在本發明之其他實施方式中,所述標記區域之面積也可以等於目標區域之面積,且目標區域處於標記區域中;所述標記區域之形狀也可以是圓形、長方形等其他形狀。For example, please refer to FIG. 2 which is a schematic diagram of the calibration area of the target object positioning method in the image provided by the first embodiment of the present invention. The processor in the imaging device obtains the image information of the image to be recognized, and obtains the characteristic information of the target area to be recognized from the data. The database stores the historical characteristic information of the target area to be recognized, and the processor Search for the target area with the characteristic information in the image to be recognized, and in the image to be recognized, the processor performs matching search with the characteristic information in the database, and marks the marked area containing the target area , As shown in the seven small boxes in Figure 2. 7 marked areas are marked in Figure 2, and each of the marked areas contains a complete target area, and the area of the marked area is larger than the area of the target area. Among the seven marked areas shown in Figure 2, because Some adjacent target areas are closely spaced. In some marked areas, not only a complete target area is included, but also some other target areas adjacent to the complete target area are included. In other embodiments of the present invention, the area of the marking area may also be equal to the area of the target area, and the target area is in the marking area; the shape of the marking area may also be a circle, a rectangle or other shapes.
若處理器在所述待識別圖像中沒有查找出具有所述特徵資訊之區域,則以提示資訊之形式發出未找出所述目標區域之消息。If the processor does not find an area with the characteristic information in the image to be recognized, it sends a message in the form of prompt information that the target area is not found.
處理模組103,用於對所述標記區域進行二值化處理,其中所述經過二值化處理後之目標區域之畫素點之顏色和目標區域外之畫素點之顏色不同。The
在本發明一實施方式中,請參閱圖3是本發明實施例一提供之圖像中目標物體定位方法標記區域二值化示意圖,對標定區域進行二值化處理之步驟可以為:將識別出得到所述目標區域之畫素點之顏色值賦予255,將識別得到之目標區域外之顏色值賦予0。經過二值化處理之後,如圖3所示,待識別圖像中之七個標記區域中,所述目標區域之畫素點之顏色為黑色,所述目標區域外之畫素點之顏色為白色,圖3中有四個標記區域不僅包含了一個完整之目標區域,還包含了與所述完整之目標區域相鄰之部分其他目標區域,如圖3中所示,所述部分其他目標區域畫素值經過二值化處理之後被賦予為黑色。In an embodiment of the present invention, please refer to FIG. 3 which is a schematic diagram of the binarization of the marked area of the target object positioning method in the image provided in the first embodiment of the present invention. The steps of binarizing the marked area may be: The color value of the pixel point in the target area is assigned 255, and the color value outside the recognized target area is assigned 0. After the binarization process, as shown in Figure 3, among the seven marked areas in the image to be recognized, the color of the pixel points in the target area is black, and the color of the pixel points outside the target area is White, there are four marked areas in Figure 3 that not only contain a complete target area, but also some other target areas adjacent to the complete target area, as shown in Figure 3, the part of other target areas The pixel value is given black after binarization.
查找模組104,用於在所述標記區域中識別所述目標區域之邊界畫素以及目標區域內之有效畫素。The
在本發明一實施方式中,在所述標記區域中識別所述目標區域之邊界畫素之步驟可以包括: 在標記區域中識別目標區域中每一畫素點之顏色; 並判斷所述目標區域中每一畫素點相鄰之其他八個畫素點之顏色; 若所述目標區域畫素點周圍之八個畫素同時存在與所述目標區域畫素點顏色一致之畫素點和與所述目標區域畫素點顏色不同畫素點,則所述目標區域畫素點為邊界畫素。In an embodiment of the present invention, the step of identifying boundary pixels of the target area in the marked area may include: Identify the color of each pixel in the target area in the marked area; And judging the colors of the other eight pixel points adjacent to each pixel point in the target area; If the eight pixels around the pixel point of the target area simultaneously have pixel points with the same color as the pixel points of the target area and pixel points with different colors from the pixel points of the target area, then the target area The pixel points are boundary pixels.
舉例而言,請參閱圖4 是本發明實施例一提供之圖像中目標物體定位方法目標區域邊界畫素和有效畫素示意圖。對於任意一個標記區域,按照步驟S3賦予之目標區域之顏色值查找所述標記區域中具有目標區域顏色值之畫素點,如圖4所示,目標區域之畫素點為黑色,則在標記區域中查找畫素顏色值為255之畫素點。對於任意一個顏色值為255之畫素點,查找在所述畫素點周圍之其他八個畫素點之顏色,若所述顏色值為255之畫素點周圍之其他八個畫素點同時存在顏色值為0之白色畫素點和顏色值為255之黑色畫素點,則位於所述八個畫素點中心之顏色值為255之畫素點為邊界畫素。並對所述邊界畫素之位置進行標記。For example, please refer to FIG. 4 for a schematic diagram of the boundary pixels and effective pixels of the target area in the method for locating a target object in an image according to the first embodiment of the present invention. For any marked area, according to the color value of the target area given in step S3, search for the pixel point with the color value of the target area in the marked area. As shown in Fig. 4, the pixel point of the target area is black, then the mark Find pixel points with pixel color value of 255 in the area. For any pixel point with a color value of 255, search for the colors of the other eight pixel points around the pixel point. If the color value of the other eight pixel points around the pixel point is 255 at the same time If there is a white pixel point with a color value of 0 and a black pixel point with a color value of 255, the pixel point with a color value of 255 located at the center of the eight pixel points is a boundary pixel. And mark the position of the boundary pixel.
在所述標記區域中識別所述目標區域之邊界畫素之步驟可以包括: 在標記區域中查找除所述邊界畫素以外之待標定畫素; 判斷所述待標定畫素之水準和豎直方向是否存在邊界畫素; 若所述待標定畫素之水準和豎直方向同時存在邊界畫素,則所述待標定畫素為有效畫素。The step of identifying boundary pixels of the target area in the marked area may include: Searching for pixels to be calibrated other than the boundary pixels in the marked area; Judging whether there are boundary pixels in the level and vertical direction of the pixels to be calibrated; If there are boundary pixels in both the horizontal and vertical directions of the pixel to be calibrated, the pixel to be calibrated is a valid pixel.
舉例而言,請參閱圖4 是本發明實施例一提供之圖像中目標物體定位方法目標區域邊界畫素和有效畫素示意圖。在待標記圖像中查找除邊界畫素以外之其他待標定畫素,所述待標定畫素可能是黑色畫素,也可能是白色畫素。對於任意一個待標定畫素,以所述待標定畫素為中心,分別朝水準和豎直方向判斷是否存在邊界畫素,若以所述待標定畫素為中心之水準、豎直四個方向均存在邊界畫素,則所述待標定畫素為有效畫素。For example, please refer to FIG. 4 for a schematic diagram of the boundary pixels and effective pixels of the target area in the method for locating a target object in an image according to the first embodiment of the present invention. Search for other pixels to be calibrated except boundary pixels in the image to be marked. The pixels to be calibrated may be black pixels or white pixels. For any pixel to be calibrated, take the pixel to be calibrated as the center, and judge whether there are boundary pixels in the horizontal and vertical directions respectively. If the pixel to be calibrated is the center of the horizontal and vertical directions If there are boundary pixels, the pixels to be calibrated are valid pixels.
輸出模組105,用於通過所述邊界畫素和有效畫素之位置確定並輸出所述目標區域之中心和大小。The
通過所述邊界畫素和有效畫素之位置確定並輸出所述目標區域之中心和大小之方法可以包括: 按照標記區域中之邊界畫素和有效畫素之位置確定目標區域之形狀; 根據所述目標區域之形狀計算所述目標區域之大小及中心。The method of determining and outputting the center and size of the target area through the positions of the boundary pixels and effective pixels may include: Determine the shape of the target area according to the position of the boundary pixels and the effective pixels in the marked area; Calculate the size and center of the target area according to the shape of the target area.
舉例而言,步驟S4確認之所述邊界畫素和有效畫素之位置,將所述邊界畫素進行連線,得到目標區域之形狀為四邊形,根據四邊形之中心及面積計算公式得到所述目標區域之中心如圖5圖像中目標物體定位方法定位結果示意圖所示。For example, the position of the boundary pixels and the effective pixels confirmed in step S4, the boundary pixels are connected to obtain the shape of the target area as a quadrilateral, and the target is obtained according to the center and area calculation formula of the quadrilateral The center of the area is shown in the schematic diagram of the positioning result of the target object positioning method in the image in Figure 5.
實施例三Example three
圖7為本發明電腦裝置較佳實施例之示意圖。FIG. 7 is a schematic diagram of a preferred embodiment of the computer device of the present invention.
本發明中之圖像中目標物體定位方法應用在電腦裝置1中。所述電腦裝置1可以為安裝有圖像中目標物體定位方法軟體之電子設備,例如個人電腦、伺服器等,其中,所述伺服器可以是單一之伺服器、伺服器集群或雲伺服器等。The method for locating a target object in an image in the present invention is applied in the
所述電腦裝置1包括記憶體20、處理器30以及存儲在所述記憶體20中並可在所述處理器30上運行之電腦程式40,例如圖像中目標物體定位程式。所述處理器30執行所述電腦程式40時實現上述圖像中目標物體定位方法實施例中之步驟,例如圖1所示之步驟S1~S5。或者,所述處理器30執行所述電腦程式40時實現上述圖像中目標物體定位裝置實施例中各模組/單元之功能,例如圖6中之單元101-105。The
示例性之,所述電腦程式40可以被分割成一個或多個模組/單元,所述一個或者多個模組/單元被存儲在所述記憶體20中,並由所述處理器30執行,以完成本發明。所述一個或多個模組/單元可以是能夠完成特定功能之一系列電腦程式指令段,所述指令段用於描述所述電腦程式40在所述電腦裝置1中之執行過程。例如,所述電腦程式40可以被分割成圖7中之獲取模組101、標識模組102、處理模組103、查找模組104、輸出模組105。Exemplarily, the
所述電腦裝置1可以是桌上型電腦、筆記本、掌上型電腦及雲端伺服器等計算設備。本領域技術人員可以理解,所述示意圖僅僅是電腦裝置1之示例,並不構成對電腦裝置1之限定,可以包括比圖示更多或更少之部件,或者組合某些部件,或者不同之部件,例如所述電腦裝置1還可以包括輸入輸出設備、網路接入設備、匯流排等。The
所稱處理器30可以是中央處理單元(Central Processing Unit,CPU),還可以是其他通用處理器、數位訊號處理器 (Digital Signal Processor,DSP)、專用積體電路 (Application Specific Integrated Circuit,ASIC)、現成可程式設計閘陣列 (Field-Programmable Gate Array,FPGA) 或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件等。通用處理器可以是微處理器或者所述處理器30也可以是任何常規之處理器等,所述處理器30是所述電腦裝置1之控制中心,利用各種介面和線路連接整個電腦裝置1之各個部分。The so-called
所述記憶體20可用於存儲所述電腦程式40和/或模組/單元,所述處理器30通過運行或執行存儲在所述記憶體20內之電腦程式和/或模組/單元,以及調用存儲在記憶體20內之資料,實現所述電腦裝置1之各種功能。所述記憶體20可主要包括存儲程式區和存儲資料區,其中,存儲程式區可存儲作業系統、至少一個功能所需之應用程式(比如聲音播放功能、圖像播放功能等)等;存儲資料區可存儲根據電腦裝置1之使用所創建之資料(比如音訊資料、電話本等)等。此外,記憶體20可以包括高速隨機存取記憶體,還可以包括非易失性記憶體,例如硬碟、記憶體、插接式硬碟,智慧存儲卡(Smart Media Card, SMC),安全數位(Secure Digital, SD)卡,快閃記憶體卡(Flash Card)、至少一個磁碟記憶體件、快閃記憶體器件、或其他易失性固態記憶體件。The
所述電腦裝置1集成之模組/單元如果以軟體功能單元之形式實現並作為獨立之產品銷售或使用時,可以存儲在一個電腦可讀取存儲介質中。基於這樣之理解,本發明實現上述實施例方法中之全部或部分流程,也可以通過電腦程式來指令相關之硬體來完成,所述之電腦程式可存儲於一電腦可讀存儲介質中,所述電腦程式在被處理器執行時,可實現上述各個方法實施例之步驟。其中,所述電腦程式包括電腦程式代碼,所述電腦程式代碼可以為原始程式碼形式、物件代碼形式、可執行檔或某些中間形式等。所述電腦可讀介質可以包括:能夠攜帶所述電腦程式代碼之任何實體或裝置、記錄介質、U盤、移動硬碟、磁碟、光碟、電腦記憶體、唯讀記憶體(ROM,Read-Only Memory)、隨機存取記憶體(RAM,Random Access Memory)、電載波信號、電信信號以及軟體分發介質等。需要說明之是,所述電腦可讀介質包含之內容可以根據司法管轄區內立法和專利實踐之要求進行適當之增減,例如在某些司法管轄區,根據立法和專利實踐,電腦可讀介質不包括電載波信號和電信信號。If the integrated module/unit of the
在本發明所提供之幾個實施例中,應所述理解到,所揭露之電腦裝置和方法,可以通過其它之方式實現。例如,以上所描述之電腦裝置實施例僅僅是示意性之,例如,所述單元之劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外之劃分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed computer device and method can be implemented in other ways. For example, the computer device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other divisions in actual implementation.
另外,在本發明各個實施例中之各功能單元可以集成在相同處理單元中,也可以是各個單元單獨物理存在,也可以兩個或兩個以上單元集成在相同單元中。上述集成之單元既可以採用硬體之形式實現,也可以採用硬體加軟體功能模組之形式實現。In addition, the functional units in the various embodiments of the present invention may be integrated in the same processing unit, or each unit may exist alone physically, or two or more units may be integrated in the same unit. The above-mentioned integrated unit can be realized either in the form of hardware, or in the form of hardware plus software functional modules.
對於本領域技術人員而言,顯然本發明不限於上述示範性實施例之細節,而且在不背離本發明之精神或基本特徵之情況下,能夠以其他之具體形式實現本發明。因此,無論從哪一點來看,均應將實施例看作是示範性之,而且是非限制性之,本發明之範圍由所附權利要求而不是上述說明限定,因此旨在將落在權利要求之等同要件之含義和範圍內之所有變化涵括在本發明內。不應將權利要求中之任何附圖標記視為限制所涉及之權利要求。此外,顯然“包括”一詞不排除其他單元或步驟,單數不排除複數。權利要求中陳述之多個單元或電腦裝置也可以由同一個單元或電腦裝置通過軟體或者硬體來實現。第一,第二等詞語用來表示名稱,而並不表示任何特定之順序。For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic characteristics of the present invention. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description, and therefore it is intended to fall within the claims. All changes within the meaning and scope of the equivalent elements are included in the present invention. Any reference signs in the claims should not be regarded as limiting the involved claims. In addition, it is obvious that the word "including" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or computer devices stated in the claims can also be implemented by the same unit or computer device through software or hardware. The first, second and other words are used to denote names, but do not denote any specific order.
最後應說明之是,以上實施例僅用以說明本發明之技術方案而非限制,儘管參照較佳實施例對本發明進行了詳細說明,本領域之普通技術人員應當理解,可以對本發明之技術方案進行修改或等同替換,而不脫離本發明技術方案之精神和範圍。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be Modifications or equivalent replacements are made without departing from the spirit and scope of the technical solutions of the present invention.
1:電腦裝置 20:記憶體 30:處理器 40:電腦程式 101:獲取模組 102:標識模組 103:處理模組 104:查找模組 105:輸出模組1: computer device 20: memory 30: processor 40: computer program 101: Get modules 102: Identification Module 103: Processing Module 104: Find Module 105: output module
圖1是本發明實施例一提供之圖像中目標物體定位方法流程圖。FIG. 1 is a flowchart of a method for locating a target object in an image provided by
圖2是本發明實施例一提供之圖像中目標物體定位方法標定區域示意圖。FIG. 2 is a schematic diagram of a calibration area of a method for locating a target object in an image provided by
圖3是本發明實施例一提供之圖像中目標物體定位方法標記區域二值化示意圖。FIG. 3 is a schematic diagram of the binarization of the marked area in the method for locating the target object in the image provided by the first embodiment of the present invention.
圖4是本發明實施例一提供之圖像中目標物體定位方法目標區域邊界之和有效之示意圖。4 is a schematic diagram of the effective sum of the boundary of the target area of the method for locating the target object in the image provided by the first embodiment of the present invention.
圖5是本發明實施例一提供之圖像中目標物體定位方法定位結果示意圖。FIG. 5 is a schematic diagram of a positioning result of a method for positioning a target object in an image provided by
圖6是本發明實施例二 提供之圖像中目標物體定位裝置之結構示意圖。Fig. 6 is a schematic structural diagram of a device for positioning a target object in an image provided by the second embodiment of the present invention.
圖7是本發明實施例三提供之電腦裝置示意圖。FIG. 7 is a schematic diagram of a computer device provided in the third embodiment of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW108131958A TWI715184B (en) | 2019-09-04 | 2019-09-04 | Method and device for positioning target object in image, computer device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW108131958A TWI715184B (en) | 2019-09-04 | 2019-09-04 | Method and device for positioning target object in image, computer device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
TWI715184B TWI715184B (en) | 2021-01-01 |
TW202111598A true TW202111598A (en) | 2021-03-16 |
Family
ID=75237262
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW108131958A TWI715184B (en) | 2019-09-04 | 2019-09-04 | Method and device for positioning target object in image, computer device and storage medium |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI715184B (en) |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW514515B (en) * | 2001-12-28 | 2002-12-21 | Taiwan Nat Central University | Method for obtaining boundary data, contour and boundary category of target image and positioning and guidance of image |
CN1198235C (en) * | 2002-03-28 | 2005-04-20 | 中华电信股份有限公司 | Method and device for picking license plate area and correcting skew license plate from automobile image |
CN105588545A (en) * | 2015-12-31 | 2016-05-18 | 歌尔科技有限公司 | Multi-target positioning method and system |
CN107025452A (en) * | 2016-01-29 | 2017-08-08 | 富士通株式会社 | Image-recognizing method and image recognition apparatus |
CN108364311B (en) * | 2018-01-29 | 2020-08-25 | 深圳市亿图视觉自动化技术有限公司 | Automatic positioning method for metal part and terminal equipment |
-
2019
- 2019-09-04 TW TW108131958A patent/TWI715184B/en active
Also Published As
Publication number | Publication date |
---|---|
TWI715184B (en) | 2021-01-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020207190A1 (en) | Three-dimensional information determination method, three-dimensional information determination device, and terminal apparatus | |
US10726580B2 (en) | Method and device for calibration | |
US11094049B2 (en) | Computing device and non-transitory storage medium implementing target object identification method | |
CN112560980B (en) | Training method and device of target detection model and terminal equipment | |
CN109166156B (en) | Camera calibration image generation method, mobile terminal and storage medium | |
CN112215255A (en) | Training method of target detection model, target detection method and terminal equipment | |
CN110926475B (en) | Unmanned aerial vehicle waypoint generation method and device and electronic equipment | |
CN111368587B (en) | Scene detection method, device, terminal equipment and computer readable storage medium | |
CN110796095B (en) | Instrument template establishing method, terminal equipment and computer storage medium | |
CN112200851B (en) | Point cloud-based target detection method and device and electronic equipment thereof | |
WO2021115061A1 (en) | Image segmentation method and apparatus, and server | |
CN109165657A (en) | A kind of image feature detection method and device based on improvement SIFT | |
CN111160242A (en) | Image target detection method, system, electronic terminal and storage medium | |
CN112613380A (en) | Machine room patrol inspection method and device, electronic equipment and storage medium | |
US20220207669A1 (en) | Image correction method and computing device utilizing method | |
CN112686176A (en) | Target re-recognition method, model training method, device, equipment and storage medium | |
CN112629828B (en) | Optical information detection method, device and equipment | |
CN112102378B (en) | Image registration method, device, terminal equipment and computer readable storage medium | |
TWI715184B (en) | Method and device for positioning target object in image, computer device and storage medium | |
CN111199188B (en) | Pixel processing method, device, storage medium and equipment of remote sensing image difference map | |
CN116109784A (en) | High-precision map difference discovery method, system, medium and equipment | |
JP6365117B2 (en) | Information processing apparatus, image determination method, and program | |
CN107734324B (en) | Method and system for measuring illumination uniformity of flash lamp and terminal equipment | |
CN108734164A (en) | Card, identification card method, paint this reading machine people and storage device | |
CN114842210A (en) | Feature point matching method and device, terminal equipment and computer readable storage medium |