WO2018120097A1 - 基于计算机视觉的黑白子识别方法及*** - Google Patents

基于计算机视觉的黑白子识别方法及*** Download PDF

Info

Publication number
WO2018120097A1
WO2018120097A1 PCT/CN2016/113678 CN2016113678W WO2018120097A1 WO 2018120097 A1 WO2018120097 A1 WO 2018120097A1 CN 2016113678 W CN2016113678 W CN 2016113678W WO 2018120097 A1 WO2018120097 A1 WO 2018120097A1
Authority
WO
WIPO (PCT)
Prior art keywords
gray value
value
average gray
detection area
image
Prior art date
Application number
PCT/CN2016/113678
Other languages
English (en)
French (fr)
Inventor
牛立涛
Original Assignee
深圳配天智能技术研究院有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 深圳配天智能技术研究院有限公司 filed Critical 深圳配天智能技术研究院有限公司
Priority to PCT/CN2016/113678 priority Critical patent/WO2018120097A1/zh
Priority to CN201680026892.XA priority patent/CN107690658B/zh
Publication of WO2018120097A1 publication Critical patent/WO2018120097A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/56Extraction of image or video features relating to colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding

Definitions

  • Embodiments of the present invention relate to the field of image recognition technologies, and in particular, to a black and white sub-identification method and system based on computer vision.
  • the game system of various types of robots is increasingly rich.
  • the traditional means of detecting chess pieces in the traditional game system is to place various sensors on the board, such as photosensitive sensors or Hall sensors. This detection method requires the chess pieces and the chessboard. The transformation will result in a corresponding increase in costs and a complicated construction.
  • the visual-based chessboard recognition system can not only reduce the cost of transforming the chess pieces and the chessboard, but also make the game system more concise and easy to maintain, and more and more popularization.
  • the existing visual-based black and white chess recognition system has the intensity of the light source. Uniformity and stability have higher requirements, and the requirements for lighting conditions are also more demanding, otherwise it is prone to false detection.
  • the embodiment of the invention provides a black-and-white sub-identification method and system based on computer vision, so as to solve the technical problem of the false detection phenomenon caused by the light factor in the prior art visual-based black and white chess recognition system.
  • a technical solution adopted by the embodiment of the present invention is to provide a black and white sub-identification method based on computer vision, the method comprising:
  • the step of comparing the first region average gray value with the difference value and the summation value, and further determining the falling state of the first detection region includes:
  • the first detection region is provided with a black child, and if the first region average gray value is greater than the summation value, the first A white sub is disposed in the detection area, and if the first area average gray value is between the difference and the summation value, the first detection area is in a sub-state.
  • the method further comprises:
  • the determination threshold is a product of a reference determination threshold and a one-hund score, wherein the difference between the actual average chessboard grayscale value and the reference chessboard average grayscale value is smaller, and the percentage is smaller.
  • the determination threshold is calculated by the following formula:
  • T abs (H b - abs (HH b )) ⁇ T b / H b ;
  • T is the decision threshold
  • H b is the reference checkerboard average gray value
  • T b is the reference decision threshold
  • H is the actual checkerboard average gray value
  • abs is an absolute value function
  • the method for determining the reference determination threshold includes:
  • the reference determination threshold is set based on the reference checkerboard average grayscale value, the reference grayscale value of the sunspot, and the reference grayscale value of the white matter.
  • the reference illumination condition is such that the reference checkerboard average gray value is between 100 and 150, and the reference gray value of the sunspot is less than the reference checkerboard average gray value exceeds 50, the white matter
  • the reference grayscale value is greater than the illumination condition in which the reference checkerboard average grayscale value exceeds 50.
  • the method further comprises: acquiring actual ambient light brightness under the actual lighting condition;
  • the determination threshold the difference between the actual ambient light brightness and the reference ambient light brightness, the smaller the determination threshold.
  • the step of setting the first detection area and the second detection area on the image to be identified includes: setting the first detection area and the second detection area respectively at each grid point of the board And determining a fall state of each of the grid points, wherein the first detection area and the second detection area are set to be square, and the width of the first detection area is equal to the sunspot and/or the The diameter of the white, the width of the second detection area is equal to the three grid widths of the board.
  • the method further includes: generating corresponding characters according to the determined falling state of each of the grid points, thereby forming a character string indicating a falling state of all the grid points, wherein different falling sub-states are Different characters are represented.
  • a technical solution adopted by the embodiment of the present invention is to provide a black and white sub-identification system based on computer vision, the system comprising an image acquisition device and an image processor, wherein the image acquisition device is used in actual Acquiring an image to be recognized of the board in an illumination condition; the image processor is configured to set a first detection area and a second detection area on the image to be identified, and calculate the image to be recognized in the first detection area a first region average gray value and a second region average gray value of the image to be identified in the second detection region, wherein an area of the second detection region is larger than the first detection region and surrounds the a first detection area, the image processor further calculating a difference between the average grayscale value of the second region and the determination threshold, and a summation value of the average grayscale value of the second region and the determination threshold, and The first region average gray value is compared with the difference value and the summation value, thereby determining a falling state of the first detection region.
  • the comparison result of the image processor is that the average grayscale value of the first region is smaller than the difference, it is determined that a black spot is set in the first detection region, and if the comparison result of the image processor is If the first region average gray value is greater than the summation value, it is determined that the first detection region is provided with white, if the comparison result of the image processor is that the first region average gray value is between And between the difference value and the summation value, determining that the first detection area is in a sub-state.
  • the image capture device is further configured to acquire an adjusted reference image when the checkerboard is in a sub-state without the sub-state, and the image processor calculates an actual checkerboard average of the checkboard according to the adjusted reference image. a gray value, and determining the decision threshold based on the actual checkerboard average grayscale value and a reference checkerboard average grayscale value under the reference illumination condition, wherein the actual checkerboard average grayscale value and the reference checkerboard average The larger the difference in the gray value, the smaller the decision threshold.
  • the determination threshold is a product of a reference determination threshold and a one hundred fraction, wherein the actual chess The greater the difference between the disc average gray value and the reference board average gray value, the smaller the percentage.
  • the determination threshold is calculated by the following formula:
  • T abs (H b - abs (HH b )) ⁇ T b / H b ;
  • T is the decision threshold
  • H b is the reference checkerboard average gray value
  • T b is the reference decision threshold
  • H is the actual checkerboard average gray value
  • abs is an absolute value function
  • the image capture device is further configured to acquire, according to a reference illumination condition, a first reference image when the checkerboard is in a sub-state, and obtain, when the checkerboard is set, a black and white when the checkerboard is set. a second reference image, the image processor further calculating the reference chessboard average gray value of the chessboard according to the first reference image, calculating a reference grayscale value of the sunspot according to the second reference image, and the The reference gradation value of the white matter, and further setting the reference determination threshold value based on the reference checkerboard average gradation value, the reference gradation value of the sunspot, and the reference gradation value of the white matter.
  • the reference illumination condition is such that the reference checkerboard average gray value is between 100 and 150, and the reference gray value of the sunspot is less than the reference checkerboard average gray value exceeds 50, the white matter
  • the reference grayscale value is greater than the illumination condition in which the reference checkerboard average grayscale value exceeds 50.
  • system further comprises a light sensor for acquiring actual ambient light brightness under the actual lighting condition, the image processor according to the actual ambient light brightness and the reference ambient light brightness under the reference lighting condition
  • the determination threshold is adjusted, and the difference between the actual ambient light brightness and the reference ambient light brightness is larger, and the determination threshold is smaller.
  • the image processor sets the first detection area and the second detection area respectively at each grid point to be detected of the board, and further determines a falling state of each grid point to be detected.
  • the first detection area and the second detection area are arranged in a square shape, and the width of the first detection area is equal to the diameter of the sunspot and/or the white matter, and the width of the second detection area is equal to The three grid widths of the board.
  • the image processor respectively generates corresponding characters according to the determined falling state of each of the to-be-detected grid points, thereby forming a character string representing all the falling state of the grid point to be detected, wherein different The drop state is represented by different characters.
  • the beneficial effects of the embodiment of the present invention are: in the computer vision-based black-and-white sub-identification method and system provided by the embodiment of the present invention, the difference between the average gray value of the second region and the determination threshold is calculated according to the determination threshold value. And the summation value of the two, and then comparing the average gray value of the first region with the difference and the sum value, thereby determining the state of the falling of the first detection region, because the determination threshold is set according to the actual environment, so that the The method is adapted to different lighting conditions and reduces false detection due to light factors. Improve the recognition accuracy of black and white.
  • FIG. 1 is a schematic flow chart of a first embodiment of a computer vision-based black and white sub-identification method provided by the present invention
  • FIG. 2 is a schematic structural view of a first detection area and a second detection area in the first embodiment
  • FIG. 3 is a schematic flow chart of a second embodiment of a computer vision-based black and white sub-identification method provided by the present invention.
  • FIG. 4 is a partial flow chart of a third embodiment of a computer vision-based black and white sub-identification method provided by the present invention.
  • FIG. 5 is a partial flow chart of a fourth embodiment of a computer vision-based black and white sub-identification method provided by the present invention.
  • FIG. 6 is a schematic flow chart of a fifth embodiment of a computer vision-based black and white sub-identification method provided by the present invention.
  • FIG. 7 is a schematic structural diagram of a computer vision-based black and white sub-identification system according to a first embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a second embodiment of a computer vision based black and white sub-identification system provided by the present invention.
  • FIG. 1 is a schematic flowchart of a computer vision-based black and white sub-identification method according to a first embodiment of the present invention
  • FIG. 2 is a first detection area and a second detection area in the first embodiment.
  • the difference between the average gray value of the second region and the preset determination threshold and the sum of the two are calculated, and then the average gray value of the first region is compared with the difference and the sum. Further, the state of the falling of the first detection area is determined.
  • the calibration method of this embodiment includes the following steps:
  • Step S11 Acquire an image to be recognized of the board under actual lighting conditions.
  • the image to be recognized is the image of the entire board, including the 19*19 grid.
  • the line area (see the grid line area of Figure 2), not just the image of the area to be detected.
  • Step S12 setting a first detection area and a second detection area on the image to be identified, wherein the area of the second detection area is larger than the first detection area and surrounds the first detection area.
  • setting the first detection area and the second detection area on the image to be identified means that the first detection area and the second detection area are respectively set at each grid point of the board, and then each grid point is further The falling state is determined, wherein the first detecting area and the second detecting area are arranged in a square shape, and the width of the first detecting area is equal to the diameter of the black and/or white, and the width of the second detecting area is equal to three grids of the board The width, where the three grid widths are specifically two full grid widths plus two half grid widths.
  • the first detection area and the second detection area are concentrically arranged, that is, the centers of the first detection area and the second detection area are consistent; when the first detection area is located at the edge of the board
  • the first detection area and the second detection area may be concentrically arranged, or may be set differently.
  • the second detection area does not exceed the checkerboard
  • the first detection area and the second detection area may be concentrically set.
  • the first detection area and the second detection area may be disposed differently, and the center of the first detection area is farther from the center of the second detection area than the edge of the board.
  • Step S13 calculating a first region average gray value of the image to be recognized in the first detection area and a second region average gray value of the image to be identified in the second detection area.
  • the gray value refers to the color depth or the difference between light and dark in the black and white image.
  • the gray value ranges from 0 to 255, where white is 255 and black is 0.
  • the average gray value is obtained by summing the gray values of all the pixels and dividing by the sum of the number of pixels, thereby obtaining the first region average gray value H n and the image to be recognized in the first detection region.
  • Step S14 Calculating a difference between the second region average gray value and the preset determination threshold and a summation value of the second region average gray value and the preset determination threshold.
  • the decision threshold can be fixed.
  • the determination threshold is a fixed value set according to experience, or a reference determination threshold under reference illumination conditions, wherein the specific determination manner of the reference determination threshold is as follows.
  • the determination threshold may also be changed, for example, calculated according to a preset algorithm, and the specific calculation manner of calculating the determination threshold according to a preset algorithm is as follows.
  • the unit of the determination threshold is a gray value, and the determination threshold is set to T, and the difference between the average gray value of the second region and the determination threshold is calculated as (H m -T), the average gray value of the second region and the determination threshold.
  • the summed value is set to (H m +T).
  • Step S15 comparing the first region average gray value with the difference value and the summation value, thereby determining the falling state of the first detection region.
  • the determination threshold since the determination threshold is provided, the difference between the average gray value of the second region and the determination threshold and the sum of the two values are calculated, and then The first region average gray value is compared with the difference value and the summation value, thereby determining the falling state of the first detection region, because the determination threshold is set according to the actual environment, so that the method is adapted to different lighting conditions, reducing The false detection caused by the light factor improves the recognition accuracy of the black and white sub-score.
  • the step S15 is further specifically: if the first region average gray value is less than the difference, the first detection region is provided with a sunspot, and if the first region average gray value is greater than the summation value, the first detection region is set. There is a white sub-, if the first region average gray value is between the difference and the summation value, the first detection region is in a sub-state.
  • the first detection region is provided with a sunspot; if the first region average gray value is greater than the summation value , that is, (H n >(H m +T)), white matter is set in the first detection region; if the average gray value of the first region is between the difference and the summation value, ie ((H m -T) ) ⁇ H n ⁇ (H m + T)), the first detection area is in a sub-state.
  • FIG. 3 is a schematic flowchart diagram of a second embodiment of a computer vision-based black and white sub-identification method provided by the present invention.
  • the determination threshold is further determined based on the actual board average gray value and the reference board average gray value under the reference lighting condition.
  • the calibration method of this embodiment includes the following steps:
  • Steps S21-S25 are substantially the same as steps S11-S15 of the first embodiment, and are not described herein again.
  • the difference between this embodiment and the first embodiment is that the embodiment further includes the following steps before step S21:
  • Step S201 Acquire an adjustment reference image when the board is in a sub-state without being in actual lighting conditions.
  • the adjustment reference image is obtained when the board is in the sub-state.
  • the actual lighting conditions include excessive light, too dark light, uneven light or unstable light.
  • it means that there is no chessboard. Falling into the sunspot or white, adjusting the reference image is just a 19*19 gridline area.
  • Step S202 Calculate the actual average gray value of the chessboard according to the adjusted reference image.
  • the actual average gray value H of the board of the 19*19 grid line is calculated.
  • Step S203 determining a determination threshold according to the actual checkerboard average gray value and the reference checkerboard average gray value under the reference illumination condition, wherein the difference between the actual checkerboard average grayscale value and the reference checkerboard average grayscale value is larger, and the determination threshold is smaller.
  • the image to be recognized of the board is obtained under a preset set of illumination conditions, and the black sub-gray value and the white sub-gray value on the to-be-identified image satisfy a preset condition, and the set of illumination conditions is a reference illumination condition.
  • the average gray value of the image to be recognized that acquires the board without the sub-state under the reference illumination condition is the average gray value of the reference board.
  • the reference board average gray value is a fixed value.
  • the preset condition may be that the average value of the reference board is within a specified range.
  • the determination threshold is a product of the reference determination threshold and the one hundred fraction, wherein the difference between the actual average chessboard gradation value and the reference chessboard average gradation value is larger, and the percentage is smaller.
  • the specific calculation method of the reference determination threshold please refer to the following.
  • the decision threshold is calculated by the following formula:
  • T abs (H b - abs (HH b )) ⁇ T b / H b ;
  • T is the decision threshold
  • H b is the reference checkerboard average gray value
  • T b is the reference decision threshold
  • H is the actual checkerboard average gray value
  • abs is the absolute value function.
  • the determination threshold T is an integer.
  • FIG. 4 is a schematic flowchart of determining a reference determination threshold in a computer vision-based black and white sub-identification method provided by the present invention.
  • the reference determination threshold is set based on the reference checkerboard average gradation value, the reference gradation value of the sunspot, and the reference gradation value of the white matter.
  • the calibration method of this embodiment includes the following steps:
  • Step S301 Acquire a first reference image when the board is in a sub-state without under the reference illumination condition.
  • the reference illumination condition is such that the reference board average gray value is between 100 and 150, and the reference gray value of the sunspot is less than the reference board average gray value exceeds 50, and the white matter reference gray value is greater than the reference board average gray value exceeds 50 lighting conditions.
  • the reference illumination condition refers to the first reference image when the board is in the sub-state without natural light and the light is uniform, that is, a gray image or a color image.
  • Step S302 Calculate a reference chessboard average gray value of the board according to the first reference image.
  • Gray level refers to black and white display
  • the difference between the brightness and the darkness of the displayed pixel points is different in color display in the color display.
  • the gray level depends on the number of bits of the refresh memory cell corresponding to each pixel and the performance of the display itself. When the display is black and white, the gray level can be directly obtained; when the display is colored, calculation is required to obtain the gray level.
  • RGB red, green and blue
  • Gray R * 0.3 + G * 0.59 + B * 0.11;
  • Gray (R * 30 + G * 59 + B * 11) / 100;
  • Gray (R * 77 + G * 151 + B * 28) >> 8;
  • R, G, and B in the original RGB (R, G, B) are uniformly replaced by Gray, and generally obtained by the average method.
  • the average gray value of the reference board in the reference lighting condition is generally between 100 and 150, and may be 120, 130 or 140.
  • the actual measured reference board average gray value exceeds 100 to 150 under the reference illumination condition, it is set such that the reference board average gray value is between 100 and 150.
  • Step S303 Acquire a second reference image when the board is provided with sunspots and whites under the reference illumination condition.
  • Step S304 Calculate the reference gray value of the sunspot and the reference gray value of the white matter according to the second reference image.
  • the sunspots and whites were taken under reference lighting conditions to obtain the reference gray values of the sunspots and whites, respectively. See the above for specific calculation methods.
  • the reference gray value of the sunspot is less than 50 of the reference board average gray value, and the white matter reference gray value is greater than the reference board average gray value by more than 50.
  • the reference gray value of the sunspot ranges from 0 to 50, optionally 20, 30 or 40; the reference gray value of the white sub-range ranges from 200 to 255, optionally 210, 225 or 235.
  • Step S305 The reference determination threshold is set based on the reference checkerboard average gradation value, the reference gradation value of the sunspot, and the reference gradation value of the white matter.
  • the reference determination threshold is set according to the reference checkerboard average gray value, the reference gray value of the sunspot, and the reference gray value of the white matter, wherein the reference gray value of the sunspot and the reference gray value of the white matter do not change much, and the reference is mainly made to the reference chessboard. Average gray value.
  • the reference determination threshold is one-half of a difference between a reference chessboard average gray value and a sunspot reference gray value or a difference between a white sub-reference gray value and a reference chessboard average gray value.
  • One of the points, at this time, according to the benchmark decision threshold can better separate the state of the board black, white or no child; wherein the two differences are subject to the smaller, and one-half of the difference is rounded to Integer.
  • the reference gray value of the sunspot is 25
  • the reference gray value of the white matter is 235
  • the average value of the reference chessboard is 125
  • the reference determination threshold can be determined to be one-half of the difference 100, and the reference is obtained.
  • the decision threshold is 50.
  • the gray value is 75 or less for the sunspot, the gray value is 175 or more for the white, and the gray value is between 75 and 175.
  • the steps of calculating the reference chessboard average gray value and the reference determination threshold are added, so that the determination threshold is based on the reference chessboard average gray value and the reference.
  • the decision threshold is set such that the method is further adapted to the light conditions of natural light, further reducing false detections due to the light factor of the checkerboard.
  • FIG. 5 is a partial flow chart of a fourth embodiment of a computer vision-based black and white sub-identification method provided by the present invention.
  • the determination threshold is adjusted by the actual ambient light luminance and the reference ambient light luminance under the reference illumination conditions.
  • the calibration method of this embodiment includes the following steps:
  • step S201 - step S203 is replaced with step S401 - step S402:
  • Step S401 Acquire actual ambient light brightness under actual lighting conditions.
  • Luminance refers to the physical quantity of the illuminant surface, and the unit of brightness is candela/square meter (cd/m2), which is the human perception of the intensity of light. Adjusting the decision threshold based on the actual ambient light brightness and the reference ambient light level under the reference illumination conditions is another embodiment.
  • Step S402 The determination threshold is adjusted according to the actual ambient light brightness and the reference ambient light brightness under the reference illumination condition, and the difference between the actual ambient light brightness and the reference ambient light brightness is larger, and the determination threshold is smaller.
  • FIG. 6 is a schematic flowchart diagram of a fifth embodiment of a computer vision-based black-and-white sub-identification method provided by the present invention.
  • the determination threshold is adjusted in accordance with the actual ambient light luminance and the reference ambient light luminance under the reference illumination conditions.
  • the calibration method of this embodiment includes the following steps:
  • Steps S51-S55 are substantially the same as steps S11-S15 of the first embodiment, and are not described herein again.
  • the difference between this embodiment and the first embodiment is that the embodiment further includes after step S55:
  • Step S56 respectively generate corresponding characters according to the determined falling state of each grid point, thereby forming a character string indicating the falling state of all the grid points, wherein different falling sub-states are represented by different characters.
  • setting the first detection area and the second detection area on the image to be identified means that the first detection area and the second detection area are respectively set on each grid point of the board, and then the falling state of each grid point is further Determining, wherein the first detection area and the second detection area are arranged in a square shape, and the width of the first detection area is equal to the diameter of the black and/or white, and the width of the second detection area is greater than or equal to the two grid widths of the board .
  • the width of the second detection area is greater than the width of the two grids of the board, including the area of 3*3.
  • the corresponding character is generated as n. Includes three.
  • the result is packed before the output, which can be started from the upper left corner and packed in rows, for example, the result of the 3x3 grid is packaged as the string nnnbnwnnn, and the string can be sent out.
  • FIG. 7 is a schematic structural diagram of a computer vision-based black and white sub-identification system according to a first embodiment of the present invention.
  • the computer vision-based black and white sub-identification system 10 includes an image acquisition device 11 and an image processor 13, and the image acquisition device 11 is electrically connected to the image processor 13, wherein the image acquisition device 11 is composed of a camera and a lens.
  • the image acquisition device 11 is composed of a camera and a lens.
  • it is a CCD camera and a CCTV lens ("Closed Circuit Television", CCTV for short).
  • the CCTV lens is a lens used by a closed circuit television, and can also be called a surveillance lens.
  • the CCD camera is mounted at an appropriate distance directly above the board, with a CCTV lens of appropriate focal length to enable the CCD camera to capture the entire board exactly;
  • the image processor 13 is composed of a visual industrial control machine and visual processing software.
  • the image capturing device 11 is configured to acquire an image to be recognized of the board under actual lighting conditions; the image processor 13 is configured to set a first detecting area and a second detecting area on the image to be recognized, and calculate an image to be recognized. a first region average gray value in the first detection area and a second region average gray value in the second detection area, wherein the area of the second detection area is larger than the first detection area and surrounds the first detection.
  • the image processor 13 further calculates a difference between the average gray value of the second region and the determination threshold, and a sum of the average gray value of the second region and the determination threshold, and compares the average gray value of the first region with the difference The summation value is compared to determine the drop state of the first detection area, wherein the difference between the actual illumination condition and the reference illumination condition is larger, and the determination threshold is smaller.
  • the image acquisition device 11 is further configured to: when the actual illumination condition is obtained, obtain an adjustment reference image when the board is in a sub-state, obtain a first reference image when the board is in a sub-state under the reference illumination condition, and under the reference illumination condition Obtain a second reference image when the board is set with sunspots and whites.
  • the other corresponding steps in the foregoing method embodiment are all performed by the image processor 13 of the identification system 10. Therefore, the image processor 13 will not be described here. For details, refer to the description of the corresponding steps above.
  • FIG. 8 is a schematic structural diagram of a second embodiment of a computer vision based black and white sub-identification system provided by the present invention.
  • the computer vision based black and white sub-identification system 20 further includes a light sensor 22, and the image capture device 21 and the light sensor 22 are electrically coupled to the image processor 23, respectively.
  • the photosensor 22 of the present embodiment is used to obtain the actual ambient light brightness under actual illumination conditions, and the image processor 23 determines the determination threshold according to the actual ambient light brightness and the reference ambient light brightness under the reference illumination condition, the actual ambient light brightness and the reference environment. The greater the difference in brightness, the smaller the decision threshold.
  • the light sensor 22 is a natural light sensor, that is, a solar light sensor.
  • the solar sensor can identify 180 degrees in the horizontal and vertical directions, or specify the angle; it can also identify the location of the sun and identify cloudy, cloudy, semi-cloudy, sunny and evening days; tracking position recognition can also be performed.
  • the lightness measurement range of the photosensor 22 is 0-100 cd/m2.
  • the image capturing device 21 and the light sensor 22 may be used in combination, and a specific light source may be further added to improve the lighting conditions, or only natural light may be used instead of the light source.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

本发明实施例公开了一种基于计算机视觉的黑白子识别方法及***,包括:在实际光照条件下获取棋盘的待识别图像;在待识别图像上设置第一检测区域和第二检测区域;计算第一检测区域内的第一区域平均灰度值及第二检测区域内的第二区域平均灰度值;计算第二区域平均灰度值与预设的判定阈值的差值以及求和值;将第一区域平均灰度值与差值以及求和值进行比较,进而判定第一检测区域的落子状态。通过上述方式,该方法的判定阀值依据实际环境进行设定的,使得该方法适应于不同的光线条件,减少了由于光线因素导致的误检测,提高黑白子的识别准确率。

Description

基于计算机视觉的黑白子识别方法及*** 【技术领域】
本发明实施例涉及图像识别技术领域,特别是涉及一种基于计算机视觉的黑白子识别方法及***。
【背景技术】
目前,各类机器人的对弈***日益丰富,然而传统的对弈***中对棋子的检测手段还是以在棋盘上安置各类传感器,如光敏传感器或者霍尔传感器,这种检测手段需要对棋子和棋盘进行改造,从而导致成本会相应的提升,而且构造复杂。
基于视觉的棋盘识别***不仅可以降低改造棋子及棋盘的成本,而且还可以使对弈***更加简洁易于维护,得到越来越多的推广,然而现有基于视觉的黑白棋识别***对于光源的强度、均匀性、稳定性均具有较高的要求,对于打光条件要求也比较苛刻,否则容易出现误检测的现象。
【发明内容】
本发明实施例提供一种基于计算机视觉的黑白子识别方法及***,以解决现有技术中基于视觉的黑白棋识别***由于光线因素产生误检测现象的技术问题。
为解决上述技术问题,本发明实施例采用的一个技术方案是:提供一种基于计算机视觉的黑白子识别方法,所述方法包括:
在实际光照条件下获取棋盘的待识别图像;
在所述待识别图像上设置第一检测区域和第二检测区域,其中所述第二检测区域的面积大于所述第一检测区域且包围所述第一检测区域;
计算所述待识别图像在所述第一检测区域内的第一区域平均灰度值及所述待识别图像在所述第二检测区域内的第二区域平均灰度值;
计算所述第二区域平均灰度值与预设的判定阈值的差值,以及计算所述第二区域平均灰度值和所述预设的判定阈值的求和值;
将所述第一区域平均灰度值与所述差值以及所述求和值进行比较,进而判定所述第一检测区域的落子状态。
其中,所述将所述第一区域平均灰度值与所述差值和所述求和值进行比较,进而判定所述第一检测区域的落子状态的步骤包括:
若所述第一区域平均灰度值小于所述差值,则所述第一检测区域内设置有黑子,若所述第一区域平均灰度值大于所述求和值,则所述第一检测区域内设置有白子,若所述第一区域平均灰度值介于所述差值与所述求和值之间,则所述第一检测区域处于无子状态。
其中,所述方法进一步包括:
在所述实际光照条件下获取所述棋盘处于无子状态时的调整参考图像;
根据所述调整参考图像计算所述棋盘的实际棋盘平均灰度值;
根据所述实际棋盘平均灰度值与所述基准光照条件下的基准棋盘平均灰度值来确定所述判定阈值,其中所述实际棋盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述判定阈值越小。
其中,所述判定阈值为基准判定阈值与一百分数的乘积,其中所述实际棋盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述百分数越小。
其中,所述判定阈值通过如下公式计算:
T=abs(Hb-abs(H-Hb))×Tb/Hb
其中,T为所述判定阈值,Hb为所述基准棋盘平均灰度值,Tb为所述基准判定阈值,所述H为所述实际棋盘平均灰度值,abs为绝对值函数。
其中,确定所述基准判定阈值的方法包括:
在基准光照条件下获取所述棋盘处于无子状态时的第一基准图像;
根据所述第一基准图像计算所述棋盘的所述基准棋盘平均灰度值;
在所述基准光照条件下获取所述棋盘设置有黑子和白子时的第二基准图像;
根据所述第二基准图像计算所述黑子的基准灰度值和所述白子的基准灰度值;
根据所述基准棋盘平均灰度值、所述黑子的基准灰度值和所述白子的基准灰度值设置所述基准判定阈值。
其中,所述基准光照条件为使得所述基准棋盘平均灰度值介于100到150之间,且所述黑子的基准灰度值小于所述基准棋盘平均灰度值超过50,所述白子的基准灰度值大于所述基准棋盘平均灰度值超过50的光照条件。
其中,所述方法进一步包括:获取所述实际光照条件下的实际环境光亮度;
根据所述实际环境光亮度与所述基准照明条件下的基准环境光亮度来调整 所述判定阈值,所述实际环境光亮度与基准环境光亮度的差异越大,所述判定阈值越小。
其中,所述在所述待识别图像上设置第一检测区域和第二检测区域的步骤包括:在所述棋盘的每个网格点分别设置所述第一检测区域和所述第二检测区域,进而对每个网格点的落子状态进行判定,其中所述第一检测区域和所述第二检测区域设置成正方形,且所述第一检测区域的宽度等于所述黑子和/或所述白子的直径,所述第二检测区域的宽度等于所述棋盘的三个网格宽度。
其中,所述方法进一步包括:根据所判定的每个所述网格点的落子状态分别生成对应的字符,进而形成表示所有所述网格点的落子状态的字符串,其中不同的落子状态由不同的字符进行表示。
为解决上述技术问题,本发明实施例采用的一个技术方案是:提供一种基于计算机视觉的黑白子识别***,所述***包括图像采集设备以及图像处理器,所述图像采集设备用于在实际光照条件下获取棋盘的待识别图像;所述图像处理器用于在所述待识别图像上设置第一检测区域和第二检测区域,并计算所述待识别图像在所述第一检测区域内的第一区域平均灰度值及所述待识别图像在所述第二检测区域内的第二区域平均灰度值,其中所述第二检测区域的面积大于所述第一检测区域且包围所述第一检测区域,所述图像处理器进一步计算所述第二区域平均灰度值与判定阈值的差值以及所述第二区域平均灰度值和所述判定阈值的求和值,并将所述第一区域平均灰度值与所述差值和所述求和值进行比较,进而判定所述第一检测区域的落子状态。
其中,若所述图像处理器的比较结果为所述第一区域平均灰度值小于所述差值,则判定所述第一检测区域内设置有黑子,若所述图像处理器的比较结果为所述第一区域平均灰度值大于所述求和值,则判定所述第一检测区域内设置有白子,若所述图像处理器的比较结果为所述第一区域平均灰度值介于所述差值与所述求和值之间,则判定所述第一检测区域处于无子状态。
其中,所述图像采集设备进一步用于在所述实际光照条件下获取所述棋盘处于无子状态时的调整参考图像,所述图像处理器根据所述调整参考图像计算所述棋盘的实际棋盘平均灰度值,并根据所述实际棋盘平均灰度值与所述基准光照条件下的基准棋盘平均灰度值来确定所述判定阈值,其中所述实际棋盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述判定阈值越小。
其中,所述判定阈值为基准判定阈值与一百分数的乘积,其中所述实际棋 盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述百分数越小。
其中,所述判定阈值通过如下公式计算:
T=abs(Hb-abs(H-Hb))×Tb/Hb
其中,T为所述判定阈值,Hb为所述基准棋盘平均灰度值,Tb为所述基准判定阈值,所述H为所述实际棋盘平均灰度值,abs为绝对值函数。
其中,所述图像采集设备进一步用于在基准光照条件下获取所述棋盘处于无子状态时的第一基准图像,且在所述基准光照条件下获取所述棋盘设置有黑子和白子时的第二基准图像,所述图像处理器进一步根据所述第一基准图像计算所述棋盘的所述基准棋盘平均灰度值,根据所述第二基准图像计算所述黑子的基准灰度值和所述白子的基准灰度值,并进一步根据所述基准棋盘平均灰度值、所述黑子的基准灰度值和所述白子的基准灰度值设置所述基准判定阈值。
其中,所述基准光照条件为使得所述基准棋盘平均灰度值介于100到150之间,且所述黑子的基准灰度值小于所述基准棋盘平均灰度值超过50,所述白子的基准灰度值大于所述基准棋盘平均灰度值超过50的光照条件。
其中,所述***进一步包括光传感器,用于获取所述实际光照条件下的实际环境光亮度,所述图像处理器根据所述实际环境光亮度与所述基准照明条件下的基准环境光亮度来调整所述判定阈值,所述实际环境光亮度与基准环境光亮度的差异越大,所述判定阈值越小。
其中,所述图像处理器在所述棋盘的每个待检测网格点分别设置所述第一检测区域和所述第二检测区域,进而对每个待检测网格点的落子状态进行判定,其中所述第一检测区域和所述第二检测区域设置成正方形,且所述第一检测区域的宽度等于所述黑子和/或所述白子的直径,所述第二检测区域的宽度等于所述棋盘的三个网格宽度。
其中,所述图像处理器根据所判定的每个所述待检测网格点的落子状态分别生成对应的字符,进而形成表示所有所述待检测网格点的落子状态的字符串,其中不同的落子状态由不同的字符进行表示。
本发明实施例的有益效果是:在本发明实施例所提供的基于计算机视觉的黑白子识别方法及***中由于设有判定阀值,根据计算第二区域平均灰度值与判定阈值的差值以及两者求和值,然后将第一区域平均灰度值与差值和求和值进行比较,进而判定第一检测区域的落子状态,因判定阀值是依据实际环境设定的,使得该方法适应于不同的光线条件,减少了由于光线因素导致的误检测, 提高黑白子的识别准确率。
【附图说明】
图1是本发明提供的基于计算机视觉的黑白子识别方法第一实施方式的流程示意图;
图2是第一实施方式中第一检测区域和第二检测区域的结构示意图;
图3是本发明提供的基于计算机视觉的黑白子识别方法第二实施方式的流程示意图;
图4是本发明提供的基于计算机视觉的黑白子识别方法第三实施方式的部分流程示意图;
图5是本发明提供的基于计算机视觉的黑白子识别方法第四实施方式的部分流程示意图;
图6是本发明提供的基于计算机视觉的黑白子识别方法第五实施方式的流程示意图;
图7是本发明提供的基于计算机视觉的黑白子识别***第一实施例的结构示意图;
图8是本发明提供的基于计算机视觉的黑白子识别***第二实施例的结构示意图。
【具体实施方式】
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
请一并参阅图1和图2,图1是本发明提供的基于计算机视觉的黑白子识别方法第一实施方式的流程示意图,图2是第一实施方式中第一检测区域和第二检测区域的结构示意图。在本实施例中,根据计算第二区域平均灰度值与预设的判定阈值的差值以及两者的求和值,然后将第一区域平均灰度值与差值和求和值进行比较,进而判定第一检测区域的落子状态。具体来说,本实施例的标定方法包括以下步骤:
步骤S11:在实际光照条件下获取棋盘的待识别图像。
在实际光照条件下获取棋盘的待识别图像,实际光照条件包括光线过强、光线过暗、光线不均匀或者光线不稳定等等情况,待识别图像是整个棋盘的图像,包括19*19网格线区域(见图2的网格线区域),而不仅仅是待检测区域的图像。
步骤S12:在待识别图像上设置第一检测区域和第二检测区域,其中第二检测区域的面积大于第一检测区域且包围第一检测区域。
如图2所示,在待识别图像上设置第一检测区域和第二检测区域是指在棋盘的每个网格点分别设置第一检测区域和第二检测区域,进而对每个网格点的落子状态进行判定,其中,第一检测区域和第二检测区域设置成正方形,且第一检测区域的宽度等于黑子和/或白子的直径,第二检测区域的宽度等于棋盘的三个网格宽度,其中,三个网格宽度具体为两个完整的网格宽度外加两个二分之一的网格宽度。
具体的,当第一检测区域位于棋盘的中部时,第一检测区域和第二检测区域同心设置,即第一检测区域和第二检测区域的中心一致;当第一检测区域位于棋盘的最边缘处时,第一检测区域和第二检测区域可以同心设置,或者不同心设置,举例来说,当第二检测区域时未超出棋盘时,第一检测区域和第二检测区域可以同心设置,当第二检测区域时超出棋盘时,第一检测区域和第二检测区域可以不同心设置,且第一检测区域的中心较第二检测区域的中心远离棋盘的边缘处。
步骤S13:计算待识别图像在第一检测区域内的第一区域平均灰度值及待识别图像在第二检测区域内的第二区域平均灰度值。
灰度值是指黑白图像中点的颜色深度或者亮暗差别,灰度值范围一般从0到255,其中,白色为255,黑色为0。平均灰度值是将所有像素点的灰度值进行求和后再除以求和的像素点个数,从而计算获得第一检测区域内的第一区域平均灰度值Hn及待识别图像在第二检测区域内的第二区域平均灰度值Hm
步骤S14:计算第二区域平均灰度值与预设的判定阈值的差值以及第二区域平均灰度值和预设的判定阈值的求和值。
判定阈值可以是固定的。例如,判定阈值是根据经验而设定的一个固定值,或者是基准光照条件下的基准判定阈值,其中,基准判定阈值的具体确定方式请参考下文。判定阈值还可以是变化的,例如根据预设的算法计算得出,根据预设的算法计算得出判定阈值的具体计算方式请参考下文。判定阈值的单位为 灰度值,判定阈值设为T,计算得出第二区域平均灰度值与判定阈值的差值设为(Hm-T),第二区域平均灰度值和判定阈值的求和值设为(Hm+T)。
步骤S15:将第一区域平均灰度值与差值以及求和值进行比较,进而判定第一检测区域的落子状态。
在本发明实施例所提供的基于计算机视觉的黑白子识别方法及***中由于设有判定阀值,根据计算第二区域平均灰度值与判定阈值的差值以及两者求和值,然后将第一区域平均灰度值与差值和求和值进行比较,进而判定第一检测区域的落子状态,因判定阀值是依据实际环境设定的,使得该方法适应于不同的光线条件,减少了由于光线因素导致的误检测,提高黑白子的识别准确率。
其中,步骤S15进一步具体为:若第一区域平均灰度值小于差值,则第一检测区域内设置有黑子,若第一区域平均灰度值大于求和值,则第一检测区域内设置有白子,若第一区域平均灰度值介于差值与求和值之间,则第一检测区域处于无子状态。
具体的,若第一区域平均灰度值小于差值,即(Hn<(Hm-T)),则第一检测区域内设置有黑子;若第一区域平均灰度值大于求和值,即(Hn>(Hm+T)),则第一检测区域内设置有白子;若第一区域平均灰度值介于差值与求和值之间,即((Hm-T)≤Hn≤(Hm+T)),则第一检测区域处于无子状态。
如图3所示,图3是本发明提供的基于计算机视觉的黑白子识别方法第二实施方式的流程示意图。在本实施例中,进一步根据实际棋盘平均灰度值与基准光照条件下的基准棋盘平均灰度值来确定判定阈值。具体来说,本实施例的标定方法包括以下步骤:
步骤S21-S25与第一实施例的步骤S11-S15基本一致,在此不再赘述。本实施例与第一实施例的区别之处在于,本实施例在步骤S21之前进一步包括以下步骤:
步骤S201:在实际光照条件下获取棋盘处于无子状态时的调整参考图像。
在实际光照条件下获取棋盘处于无子状态时的调整参考图像,实际光照条件包括光线过强、光线过暗、光线不均匀或者光线不稳定等等情况,无子状态时是指棋盘上还没有落入黑子或者白子,调整参考图像仅仅是19*19网格线区域。
步骤S202:根据调整参考图像计算棋盘的实际棋盘平均灰度值。
根据调整参考图像,计算19*19网格线棋盘的实际棋盘平均灰度值H。
步骤S203:根据实际棋盘平均灰度值与基准光照条件下的基准棋盘平均灰度值来确定判定阈值,其中实际棋盘平均灰度值与基准棋盘平均灰度值的差异越大,判定阈值越小。
在一组预设的光照条件下获取棋盘的待识别图像,且该待识别图像上的黑子灰度值以及白子的灰度值满足预设的条件,则该组光照条件就是基准光照条件。在基准光照条件下获取无子状态的棋盘的待识别图像的平均灰度值就是基准棋盘平均灰度值。当预设的光照条件确定时,基准棋盘平均灰度值就是一固定值。预设的条件可以是基准棋盘平均灰度值在一指定范围内。
其中,判定阈值为基准判定阈值与一百分数的乘积,其中实际棋盘平均灰度值与基准棋盘平均灰度值的差异越大,百分数越小,基准判定阈值的具体计算方式请参考下文。
具体的,判定阈值通过如下公式计算:
T=abs(Hb-abs(H-Hb))×Tb/Hb
其中,T为判定阈值,Hb为基准棋盘平均灰度值,Tb为基准判定阈值,H为实际棋盘平均灰度值,abs为绝对值函数。判定阈值T为整数。
在一实际应用例,设基准棋盘平均灰度值Hb为128,基准判定阈值Tb为30,则判定阈值计算得:T=abs(128-abs(H-128))×30/128。其中,实际棋盘平均灰度值与基准棋盘平均灰度值的差异越大,判定阈值越小。
如图4所示,图4是本发明提供的基于计算机视觉的黑白子识别方法中确定基准判定阈值的流程示意图。在本实施例中,根据基准棋盘平均灰度值、黑子的基准灰度值和白子的基准灰度值设置基准判定阈值。具体来说,本实施例的标定方法包括以下步骤:
步骤S301:在基准光照条件下获取棋盘处于无子状态时的第一基准图像。
基准光照条件为使得基准棋盘平均灰度值介于100到150之间,且黑子的基准灰度值小于基准棋盘平均灰度值超过50,白子的基准灰度值大于基准棋盘平均灰度值超过50的光照条件。在实际应用中,基准光照条件下是指自然光照条件下且光线均匀的时候,获取棋盘处于无子状态时的第一基准图像,即一张灰白图像或者彩色图像。
步骤S302:根据第一基准图像计算棋盘的基准棋盘平均灰度值。
基准光照条件下是指自然光照条件下且光线均匀的时候,基准棋盘平均灰度值是固定值,以实际得出灰度级或者计算获得灰度级。灰度级指黑白显示器 中显示像素点的亮暗差别,在彩色显示器中表现为颜色的不同,灰度级越多,图像层次越清楚逼真。灰度级取决于每个像素对应的刷新存储单元的位数和显示器本身的性能。当显示器是黑白时,可以直接得出灰度级;当显示器是彩色时,需要计算才能获得灰度级。
其中,任何颜色都由红、绿、蓝三基色组成,将原来某点的颜色为RGB(R,G,B)转换为灰度Gray时,可以通过下面五种方法:
一、浮点算法:Gray=R*0.3+G*0.59+B*0.11;
二、整数方法:Gray=(R*30+G*59+B*11)/100;
三、移位方法:Gray=(R*77+G*151+B*28)>>8;
四、平均值法:Gray=(R+G+B)/3;
五、仅取绿色:Gray=G;
通过上述任一种方法求得Gray后,将原来的RGB(R,G,B)中的R,G,B统一用Gray替换,一般采用平均值法获得。以实际的应用例说明,基准光照条件下基准棋盘平均灰度值一般介于100到150之间,可选为120、130或者140。当基准光照条件下实际测得的基准棋盘平均灰度值超过100到150之间,设置成使得基准棋盘平均灰度值介于100到150之间。
步骤S303:在基准光照条件下获取棋盘设置有黑子和白子时的第二基准图像。
步骤S304:根据第二基准图像计算黑子的基准灰度值和白子的基准灰度值。
在基准光照条件下拍摄黑子和白子,分别获得黑子和白子的基准灰度值。具体计算方法参见上文。其中,黑子的基准灰度值小于基准棋盘平均灰度值超过50,白子的基准灰度值大于基准棋盘平均灰度值超过50。换句话说,黑子的基准灰度值范围为0-50,可选为20、30或者40;白子的基准灰度值范围为200-255,可选为210、225或者235。
步骤S305:根据基准棋盘平均灰度值、黑子的基准灰度值和白子的基准灰度值设置基准判定阈值。
根据基准棋盘平均灰度值、黑子的基准灰度值和白子的基准灰度值设置基准判定阈值,其中,黑子的基准灰度值和白子的基准灰度值的变化不大,主要参考基准棋盘平均灰度值。在本实施例中,所述基准判定阈值为基准棋盘平均灰度值与黑子基准灰度值的差值的二分之一或者白子基准灰度值与基准棋盘平均灰度值的差值的二分之一,此时,依据该基准判定阈值能够较好分别出棋盘 黑子、白子或者无子的状态;其中,两个差值中以小者为准,且差值的二分之一四舍五入为整数。具体举例说明,当黑子的基准灰度值为25,白子的基准灰度值为235,基准棋盘平均灰度值为125时,即基准棋盘平均灰度值125与黑子基准灰度值25的差值100的二分之一或者白子基准灰度值235与基准棋盘平均灰度值125的差值110的二分之一,从而可以确定基准判定阈值为差值100的二分之一,获得基准判定阈值为50。在光照条件较好的情况下,依据上文判定落子状态的计算方式,即灰度值为75以下为黑子,灰度值为175以上为白子,灰度值为75-175之间即为无子状态。当光照条件不好的情况下,基准棋盘平均灰度值为125,实际棋盘平均灰度值为100时,根据公式T=abs(Hb-abs(H-Hb))×Tb/Hb;可以计算得出T=40。即灰度值为60以下为黑子,灰度值为140以上为白子,灰度值为60-140之间即为无子状态。
综上所述,在本发明实施例所提供的基于计算机视觉的黑白子识别方法中增加计算基准棋盘平均灰度值和基准判定阈值的步骤,使得判定阀值依据基准棋盘平均灰度值和基准判定阈值设定的,使得该方法进一步适应于自然光的光线条件,进一步减少了由于棋盘的光线因素导致的误检测。
如图5所示,图5是本发明提供的基于计算机视觉的黑白子识别方法第四实施方式的部分流程示意图。在本实施例中,实际环境光亮度与基准照明条件下的基准环境光亮度来调整判定阈值。具体来说,本实施例的标定方法包括以下步骤:
本实施例的流程步骤与第二实施例的流程步骤基本相同,在此不再赘述。本实施例与第二实施例的区别之处在于,将步骤S201-步骤S203更换为步骤S401-步骤S402:
步骤S401:获取实际光照条件下的实际环境光亮度。
计算实际光照条件下的实际环境光亮度。亮度是指发光体表面发光强弱的物理量,亮度的单位是坎德拉/平方米(cd/m2),是人对光的强度的感受。依据实际环境光亮度与基准照明条件下的基准环境光亮度来调整判定阈值是另一种实施方式。
步骤S402:根据实际环境光亮度与基准照明条件下的基准环境光亮度来调整判定阈值,实际环境光亮度与基准环境光亮度的差异越大,判定阈值越小。
在预设的基准环境光照条件下,所述基准环境光亮度是固定值。假设基准环境光亮度为400cd/m2,基准判定阈值为50,若实际环境光亮度为100cd/m2 时,将光亮度代入上述计算判定阈值的公式T=abs(400-abs(100-400))×50/400,其中,实际棋盘平均灰度值替换为实际环境光亮度,基准棋盘平均灰度值替换为基准环境光亮度,可以计算获得调整判定阈值为12.5,四舍五入后为整数13。其中,实际环境光亮度与基准环境光亮度的差异越大,判定阈值越小。
如图6所示,图6是本发明提供的基于计算机视觉的黑白子识别方法第五实施方式的流程示意图。在本实施例中,根据实际环境光亮度与基准照明条件下的基准环境光亮度来调整判定阈值。具体来说,本实施例的标定方法包括以下步骤:
步骤S51-S55与第一实施例的步骤S11-S15基本一致,在此不再赘述。本实施例与第一实施例的区别之处在于,本实施例在步骤S55之后进一步包括:
步骤S56:根据所判定的每个网格点的落子状态分别生成对应的字符,进而形成表示所有网格点的落子状态的字符串,其中不同的落子状态由不同的字符进行表示。
具体的,在待识别图像上设置第一检测区域和第二检测区域是指在棋盘的每个网格点分别设置第一检测区域和第二检测区域,进而对每个网格点的落子状态进行判定,其中,第一检测区域和第二检测区域设置成正方形,且第一检测区域的宽度等于黑子和/或白子的直径,第二检测区域的宽度大于或等于棋盘的两个网格宽度。本实施例中,第二检测区域的宽度大于棋盘的两个网格宽度,包括区域为3*3,当棋子为黑子时,生成对应的字符为b,当棋子为白子时,生成对应的字符为w,当为无子,生成对应的字符为n。包括三个。结果输出前将数据打包,可以由左上角开始,按行依次打包,例如3x3网格打包后结果为字符串nnnbnwnnn,将此字符串向外发送即可。
请参阅图7,图7是本发明提供的基于计算机视觉的黑白子识别***第一实施例的结构示意图。
如图7所示,该基于计算机视觉的黑白子识别***10包括图像采集设备11和图像处理器13,图像采集设备11电连接图像处理器13,其中,图像采集设备11由摄像机和镜头组成,具体为CCD摄像机和CCTV镜头(“Closed Circuit Television”,简称CCTV),CCTV镜头是闭路电视所使用的镜头,也可以叫做监控镜头。CCD摄像机安装于棋盘正上方适当距离,配以适当焦距的CCTV镜头使CCD摄像机能够恰好拍摄好整个棋盘;图像处理器13由视觉工业控制机和视觉处理软件组成。
本实施例中,图像采集设备11用于在实际光照条件下获取棋盘的待识别图像;图像处理器13用于在待识别图像上设置第一检测区域和第二检测区域,并计算待识别图像在第一检测区域内的第一区域平均灰度值及待识别图像在第二检测区域内的第二区域平均灰度值,其中第二检测区域的面积大于第一检测区域且包围第一检测区域,图像处理器13进一步计算第二区域平均灰度值与判定阈值的差值以及第二区域平均灰度值和判定阈值的求和值,并将第一区域平均灰度值与差值和求和值进行比较,进而判定第一检测区域的落子状态,其中实际光照条件与基准光照条件差异越大,判定阈值越小。
其中,图像采集设备11进一步用于在实际光照条件下获取棋盘处于无子状态时的调整参考图像、在基准光照条件下获取棋盘处于无子状态时的第一基准图像、以及在基准光照条件下获取棋盘设置有黑子和白子时的第二基准图像。而上述方法实施例中的其他对应步骤均由识别***10的图像处理器13执行,故在此不对图像处理器13进行赘述,详细请参阅以上对应步骤的说明。
请参阅图8,图8是本发明提供的基于计算机视觉的黑白子识别***第二实施例的结构示意图。
如图8所示,该基于计算机视觉的黑白子识别***20进一步包括光传感器22,图像采集设备21和光传感器22分别电连接图像处理器23。本实施的光传感器22用于获取实际光照条件下的实际环境光亮度,图像处理器23根据实际环境光亮度与基准照明条件下的基准环境光亮度来确定判定阈值,实际环境光亮度与基准环境光亮度的差异越大,判定阈值越小。光传感器22为自然光传感器,即太阳光传感器。太阳光传感器可识别水平方向和垂直方向各180度,或者指定角度;还可以识别太阳所在的位置以及识别阴天、多云天、半阴天、晴天及晚上白天;还可以进行跟踪方位识别。光传感器22的光亮度测量范围为0-10000cd/m2。在其他实施例中,可以将图像采集设备21和光传感器22合二为一进行使用,还可以进一步增加特定光源,改善光照条件,也可以仅依靠自然光而不加光源。
综上所述,本领域技术人员容易理解,在本发明实施例所提供的基于计算机视觉的黑白子识别方法及***中由于设有判定阀值,根据计算第二区域平均灰度值与预设的判定阈值的差值以及两者求和值,然后将第一区域平均灰度值与差值和求和值进行比较,进而判定第一检测区域的落子状态,因判定阀值是依据实际环境设定的,使得该方法适应于不同的光线条件,减少了由于光线因 素导致的误检测,提高黑白子的识别准确率。
以上所述仅为本发明的实施方式,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。

Claims (20)

  1. 一种基于计算机视觉的黑白子识别方法,其特征在于,所述方法包括:
    在实际光照条件下获取棋盘的待识别图像;
    在所述待识别图像上设置第一检测区域和第二检测区域,其中所述第二检测区域的面积大于所述第一检测区域且包围所述第一检测区域;
    计算所述待识别图像在所述第一检测区域内的第一区域平均灰度值及所述待识别图像在所述第二检测区域内的第二区域平均灰度值;
    计算所述第二区域平均灰度值与预设的判定阈值的差值,以及计算所述第二区域平均灰度值和所述预设的判定阈值的求和值;
    将所述第一区域平均灰度值与所述差值以及所述求和值进行比较,进而判定所述第一检测区域的落子状态。
  2. 根据权利要求1所述的基于计算机视觉的黑白子识别方法,其特征在于,所述将所述第一区域平均灰度值与所述差值和所述求和值进行比较,进而判定所述第一检测区域的落子状态的步骤包括:
    若所述第一区域平均灰度值小于所述差值,则所述第一检测区域内设置有黑子,若所述第一区域平均灰度值大于所述求和值,则所述第一检测区域内设置有白子,若所述第一区域平均灰度值介于所述差值与所述求和值之间,则所述第一检测区域处于无子状态。
  3. 根据权利要求1所述的基于计算机视觉的黑白子识别方法,其特征在于,所述方法进一步包括:
    在所述实际光照条件下获取所述棋盘处于无子状态时的调整参考图像;
    根据所述调整参考图像计算所述棋盘的实际棋盘平均灰度值;
    根据所述实际棋盘平均灰度值与基准光照条件下的基准棋盘平均灰度值来确定所述判定阈值,其中所述实际棋盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述判定阈值越小。
  4. 根据权利要求3所述的基于计算机视觉的黑白子识别方法,其特征在于,所述判定阈值为基准判定阈值与一百分数的乘积,其中所述实际棋盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述百分数越小。
  5. 根据权利要求4所述的基于计算机视觉的黑白子识别方法,其特征在于,所述判定阈值通过如下公式计算:
    T=abs(Hb-abs(H-Hb))×Tb/Hb
    其中,T为所述判定阈值,Hb为所述基准棋盘平均灰度值,Tb为所述基准判定阈值,所述H为所述实际棋盘平均灰度值,abs为绝对值函数。
  6. 根据权利要求4所述的基于计算机视觉的黑白子识别方法,其特征在于,确定所述基准判定阈值的方法包括:
    在基准光照条件下获取所述棋盘处于无子状态时的第一基准图像;
    根据所述第一基准图像计算所述棋盘的所述基准棋盘平均灰度值;
    在所述基准光照条件下获取所述棋盘设置有黑子和白子时的第二基准图像;
    根据所述第二基准图像计算所述黑子的基准灰度值和所述白子的基准灰度值;
    根据所述基准棋盘平均灰度值、所述黑子的基准灰度值和所述白子的基准灰度值设置所述基准判定阈值。
  7. 根据权利要求6所述的基于计算机视觉的黑白子识别方法,其特征在于,所述基准光照条件为使得所述基准棋盘平均灰度值介于100到150之间,且所述黑子的基准灰度值小于所述基准棋盘平均灰度值超过50,所述白子的基准灰度值大于所述基准棋盘平均灰度值超过50的光照条件。
  8. 根据权利要求1所述的基于计算机视觉的黑白子识别方法,其特征在于,所述方法进一步包括:
    获取所述实际光照条件下的实际环境光亮度;
    根据所述实际环境光亮度与所述基准照明条件下的基准环境光亮度来调整所述判定阈值,所述实际环境光亮度与基准环境光亮度的差异越大,所述判定阈值越小。
  9. 根据权利要求1所述的基于计算机视觉的黑白子识别方法,其特征在于,所述在所述待识别图像上设置第一检测区域和第二检测区域的步骤包括:
    在所述棋盘的每个网格点分别设置所述第一检测区域和所述第二检测区域,进而对每个网格点的落子状态进行判定,其中所述第一检测区域和所述第二检测区域设置成正方形,且所述第一检测区域的宽度等于所述黑子和/或所述白子的直径,所述第二检测区域的宽度等于所述棋盘的三个网格宽度。
  10. 根据权利要求9所述的基于计算机视觉的黑白子识别方法,其特征在于,所述方法进一步包括:
    根据所判定的每个所述网格点的落子状态分别生成对应的字符,进而形成表示所有所述网格点的落子状态的字符串,其中不同的落子状态由不同的字符 进行表示。
  11. 一种基于计算机视觉的黑白子识别***,其特征在于,所述***包括图像采集设备以及图像处理器,所述图像采集设备用于在实际光照条件下获取棋盘的待识别图像;所述图像处理器用于在所述待识别图像上设置第一检测区域和第二检测区域,并计算所述待识别图像在所述第一检测区域内的第一区域平均灰度值及所述待识别图像在所述第二检测区域内的第二区域平均灰度值,其中所述第二检测区域的面积大于所述第一检测区域且包围所述第一检测区域,所述图像处理器进一步计算所述第二区域平均灰度值与预设的判定阈值的差值以及所述第二区域平均灰度值和所述预设的判定阈值的求和值,并将所述第一区域平均灰度值与所述差值和所述求和值进行比较,进而判定所述第一检测区域的落子状态。
  12. 根据权利要求11所述的基于计算机视觉的黑白子识别***,其特征在于,若所述图像处理器的比较结果为所述第一区域平均灰度值小于所述差值,则判定所述第一检测区域内设置有黑子,若所述图像处理器的比较结果为所述第一区域平均灰度值大于所述求和值,则判定所述第一检测区域内设置有白子,若所述图像处理器的比较结果为所述第一区域平均灰度值介于所述差值与所述求和值之间,则判定所述第一检测区域处于无子状态。
  13. 根据权利要求11所述的基于计算机视觉的黑白子识别***,其特征在于,所述图像采集设备进一步用于在所述实际光照条件下获取所述棋盘处于无子状态时的调整参考图像,所述图像处理器根据所述调整参考图像计算所述棋盘的实际棋盘平均灰度值,并根据所述实际棋盘平均灰度值与所述基准光照条件下的基准棋盘平均灰度值来确定所述判定阈值,其中所述实际棋盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述判定阈值越小。
  14. 根据权利要求13所述的基于计算机视觉的黑白子识别***,其特征在于,所述判定阈值为基准判定阈值与一百分数的乘积,其中所述实际棋盘平均灰度值与所述基准棋盘平均灰度值的差异越大,所述百分数越小。
  15. 根据权利要求14所述的基于计算机视觉的黑白子识别***,其特征在于,所述判定阈值通过如下公式计算:
    T=abs(Hb-abs(H-Hb))×Tb/Hb
    其中,T为所述判定阈值,Hb为所述基准棋盘平均灰度值,Tb为所述基准判定阈值,所述H为所述实际棋盘平均灰度值,abs为绝对值函数。
  16. 根据权利要求14所述的基于计算机视觉的黑白子识别***,其特征在于,所述图像采集设备进一步用于在基准光照条件下获取所述棋盘处于无子状态时的第一基准图像,且在所述基准光照条件下获取所述棋盘设置有黑子和白子时的第二基准图像,所述图像处理器进一步根据所述第一基准图像计算所述棋盘的所述基准棋盘平均灰度值,根据所述第二基准图像计算所述黑子的基准灰度值和所述白子的基准灰度值,并进一步根据所述基准棋盘平均灰度值、所述黑子的基准灰度值和所述白子的基准灰度值设置所述基准判定阈值。
  17. 根据权利要求16所述的基于计算机视觉的黑白子识别***,其特征在于,所述基准光照条件为使得所述基准棋盘平均灰度值介于100到150之间,且所述黑子的基准灰度值小于所述基准棋盘平均灰度值超过50,所述白子的基准灰度值大于所述基准棋盘平均灰度值超过50的光照条件。
  18. 根据权利要求11所述的基于计算机视觉的黑白子识别***,其特征在于,所述***进一步包括光传感器,用于获取所述实际光照条件下的实际环境光亮度,所述图像处理器根据所述实际环境光亮度与所述基准照明条件下的基准环境光亮度来调整所述判定阈值,所述实际环境光亮度与基准环境光亮度的差异越大,所述判定阈值越小。
  19. 根据权利要求11所述的基于计算机视觉的黑白子识别***,其特征在于,所述图像处理器在所述棋盘的每个待检测网格点分别设置所述第一检测区域和所述第二检测区域,进而对每个待检测网格点的落子状态进行判定,其中所述第一检测区域和所述第二检测区域设置成正方形,且所述第一检测区域的宽度等于所述黑子和/或所述白子的直径,所述第二检测区域的宽度等于所述棋盘的三个网格宽度。
  20. 根据权利要求19所述的基于计算机视觉的黑白子识别***,其特征在于,所述图像处理器根据所判定的每个所述待检测网格点的落子状态分别生成对应的字符,进而形成表示所有所述待检测网格点的落子状态的字符串,其中不同的落子状态由不同的字符进行表示。
PCT/CN2016/113678 2016-12-30 2016-12-30 基于计算机视觉的黑白子识别方法及*** WO2018120097A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2016/113678 WO2018120097A1 (zh) 2016-12-30 2016-12-30 基于计算机视觉的黑白子识别方法及***
CN201680026892.XA CN107690658B (zh) 2016-12-30 2016-12-30 基于计算机视觉的黑白子识别方法及***

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/113678 WO2018120097A1 (zh) 2016-12-30 2016-12-30 基于计算机视觉的黑白子识别方法及***

Publications (1)

Publication Number Publication Date
WO2018120097A1 true WO2018120097A1 (zh) 2018-07-05

Family

ID=61151118

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/113678 WO2018120097A1 (zh) 2016-12-30 2016-12-30 基于计算机视觉的黑白子识别方法及***

Country Status (2)

Country Link
CN (1) CN107690658B (zh)
WO (1) WO2018120097A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109044845B (zh) * 2018-09-29 2021-11-16 河北盛世天昕电子科技有限公司 一种配药余量告警方法及装置
CN110349139A (zh) * 2019-07-02 2019-10-18 芜湖启迪睿视信息技术有限公司 一种基于神经网络分割的包装杂项检测方法
CN110487801B (zh) * 2019-07-30 2022-07-19 厦门三安光电有限公司 识别石墨盘高温烘烤结果的方法、装置、设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1448884A (zh) * 2003-04-24 2003-10-15 上海交通大学 基于视觉的棋盘识别***
CN102184544A (zh) * 2011-05-18 2011-09-14 北京联合大学生物化学工程学院 校畸和识别围棋棋谱图像的方法
CN105205447A (zh) * 2015-08-22 2015-12-30 周立人 基于围棋图像的围棋识别方法以及棋盘

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102614655A (zh) * 2012-03-06 2012-08-01 南京航空航天大学 围棋自动数字仪及应用于其上的棋局胜负判断方法
US9488736B2 (en) * 2012-12-28 2016-11-08 Trimble Navigation Limited Locally measured movement smoothing of GNSS position fixes

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1448884A (zh) * 2003-04-24 2003-10-15 上海交通大学 基于视觉的棋盘识别***
CN102184544A (zh) * 2011-05-18 2011-09-14 北京联合大学生物化学工程学院 校畸和识别围棋棋谱图像的方法
CN105205447A (zh) * 2015-08-22 2015-12-30 周立人 基于围棋图像的围棋识别方法以及棋盘

Also Published As

Publication number Publication date
CN107690658B (zh) 2021-02-26
CN107690658A (zh) 2018-02-13

Similar Documents

Publication Publication Date Title
CN101770646B (zh) 基于Bayer RGB图像的边缘检测方法
KR102346522B1 (ko) 영상 처리 장치 및 그것의 자동 화이트 밸런싱 방법
CN105306843B (zh) 一种图像传感器的坏点处理方法及***
US20090021526A1 (en) Determination method for white-point and correction method of the white balance
KR20140070120A (ko) 디스플레이 장치의 색 보정 장치 및 그 보정 방법
WO2016150004A1 (zh) 一种对oled显示器的待显示画面进行处理的设备和方法
WO2018120097A1 (zh) 基于计算机视觉的黑白子识别方法及***
WO2013135033A1 (zh) 基于图像分析的隧道变形在线监测***及其应用
TWI532385B (zh) 白平衡處理方法及其處理裝置
WO2022089082A1 (zh) 显示图像调整方法、终端设备及计算机可读存储介质
CN106204602B (zh) 元件反件检测方法和***
JP2009171008A (ja) 色再現装置および色再現プログラム
CN104318266B (zh) 一种图像智能分析处理预警方法
CN110784701B (zh) 显示设备及其图像处理方法
KR102022699B1 (ko) 영상 제어 표시 장치 및 영상 제어 방법
TWI670977B (zh) 不良像素補償方法與裝置
JP5468914B2 (ja) 大型映像表示装置の制御装置
WO2019041664A1 (zh) 量测显示面板的量测方法及其装置
CN102968177B (zh) 手势感测方法
US8189068B2 (en) Apparatus and method for detecting flicker noise and computer readable medium stored thereon computer executable instructions for performing the method
TWI698129B (zh) 影像處理方法及其電子裝置
KR101621201B1 (ko) 웨어러블 프로젝션 장치 및 프로젝션 방법
TW201418671A (zh) 水位量測方法
US11800040B2 (en) Black level drift
CN112581488B (zh) 基于MicroLED显示技术的显示屏

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16925757

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16925757

Country of ref document: EP

Kind code of ref document: A1