JP2018055621A - Computer program, moving body detection method and moving body detection device - Google Patents

Computer program, moving body detection method and moving body detection device Download PDF

Info

Publication number
JP2018055621A
JP2018055621A JP2016194392A JP2016194392A JP2018055621A JP 2018055621 A JP2018055621 A JP 2018055621A JP 2016194392 A JP2016194392 A JP 2016194392A JP 2016194392 A JP2016194392 A JP 2016194392A JP 2018055621 A JP2018055621 A JP 2018055621A
Authority
JP
Japan
Prior art keywords
moving object
image
brightness
processing target
target image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2016194392A
Other languages
Japanese (ja)
Other versions
JP6743633B2 (en
Inventor
靖寿 松葉
Yasuhisa Matsuba
靖寿 松葉
荘介 下山
Sosuke Shimoyama
荘介 下山
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dai Nippon Printing Co Ltd
Original Assignee
Dai Nippon Printing Co Ltd
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 Dai Nippon Printing Co Ltd filed Critical Dai Nippon Printing Co Ltd
Priority to JP2016194392A priority Critical patent/JP6743633B2/en
Publication of JP2018055621A publication Critical patent/JP2018055621A/en
Application granted granted Critical
Publication of JP6743633B2 publication Critical patent/JP6743633B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Analysis (AREA)
  • Studio Devices (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a computer program, a moving body detection method, and a moving body detection device capable of suppressing erroneous detection attributable to local brightness variation.SOLUTION: In a computer program causing a computer to detect a moving body imaged on an image, a computer storing a processing target image serving as a target of moving body detection processing is caused to execute processing including: a brightness correction step of performing brightness correction for adjusting bright distribution in the processing target image with brightness distribution in a specific reference image; and a step of performing moving body detection on the processing target image already subjected to the brightness correction.SELECTED DRAWING: Figure 4

Description

本発明は、画像から動体を検出するためのコンピュータプログラム、動体検出方法、及び動体検出装置に関する。   The present invention relates to a computer program, a moving object detection method, and a moving object detection device for detecting a moving object from an image.

カメラで撮影された動画又は繰り返し撮影された画像等の画像には、樹木又は建物等の静止した物体からなる背景と背景に対して移動する人又は自動車等の動体とが写されている。従来、撮影された画像から動体を検出するニーズがある。例えば、監視カメラで撮影された動画に動体が検出された場合に動画の録画を開始することが行われる。画像から動体を検出するには、一般的に、背景差分という方法が用いられる。背景差分とは、事前に撮影された画像と新しく撮影された画像とを比較し、事前に撮影された画像に含まれていない部分を新しく撮影された画像から動体として抽出する方法である。   In images such as moving images taken with a camera or images taken repeatedly, a background consisting of a stationary object such as a tree or a building and a moving object such as a person or a car moving relative to the background are shown. Conventionally, there is a need to detect moving objects from captured images. For example, recording of a moving image is started when a moving object is detected in the moving image captured by the surveillance camera. In general, a method called background difference is used to detect a moving object from an image. Background difference is a method of comparing a previously captured image with a newly captured image and extracting a portion not included in the previously captured image as a moving object from the newly captured image.

背景差分には、本来背景である部分を動体として誤検出することがあるという問題がある。例えば、照明環境が変化したことによる局所的な明るさ変動、又は樹木の揺動若しくは水面の変動等の局所的な背景の変化が動体として誤検出されることがある。このような問題を解決するために、種々の手法が開発されている。特許文献1には、背景差分の例が開示されている。   The background difference has a problem that a portion that is originally a background may be erroneously detected as a moving object. For example, a local brightness change due to a change in the lighting environment, or a local background change such as a tree swing or a water surface change may be erroneously detected as a moving object. Various methods have been developed to solve such problems. Patent Document 1 discloses an example of background difference.

背景差分に用いられる手法として、背景モデルを用いる手法がある。背景モデルを生成する方法には、統計情報を利用した背景モデリングを行う手法と、空間情報を利用した背景モデリングを行う手法との主に二つの手法に分けられる。統計情報を利用した背景モデリングを行う手法では、画像に含まれる画素値の時間的な変化を統計モデル化し、空間情報を利用した背景モデリングを行う手法では、画像中の注目画素及びその周辺領域での画素値の分布パターンをモデル化する。いずれの手法でも、モデルから外れた部分を動体として検出することができる。   As a method used for background difference, there is a method using a background model. There are mainly two methods for generating a background model: a method for performing background modeling using statistical information and a method for performing background modeling using spatial information. In the method of performing background modeling using statistical information, the temporal change of the pixel value included in the image is statistically modeled. In the method of performing background modeling using spatial information, the pixel of interest in the image and its surrounding area are used. The distribution pattern of the pixel values is modeled. In any of the methods, a portion outside the model can be detected as a moving object.

統計情報を利用した背景モデルを用いる手法では、局所的な背景の変化に対してはある程度ロバスト性を確保することができる。一方で、局所的な明るさ変動が動体として誤検出されるという問題がある。特に、カメラにおいて露出又はホワイトバランス等の調整により明るさを自動で補正する場合に、誤検出が増加する。また、空間情報を利用した背景モデルを用いる手法では、局所的な背景の変化に加えて、局所的な明るさ変動に対してもある程度ロバスト性を確保することが可能であり、統計情報を利用した背景モデルを用いる手法に比べて誤検出率が低い傾向がある。一方で、周辺領域の設定に応じて処理の精度及び速度が変動するので、パラメータの調整が困難であるという問題がある。   In the method using a background model using statistical information, a certain degree of robustness can be secured against local background changes. On the other hand, there is a problem that local brightness fluctuations are erroneously detected as moving objects. In particular, erroneous detection increases when the camera automatically corrects brightness by adjusting exposure or white balance. In addition, the method using a background model that uses spatial information can ensure a certain degree of robustness against local brightness fluctuations in addition to local background changes, and uses statistical information. There is a tendency that the false detection rate is lower than the method using the background model. On the other hand, since the accuracy and speed of processing vary according to the setting of the peripheral region, there is a problem that it is difficult to adjust parameters.

特開2016−76015号公報Japanese Patent Laid-Open No. 2006-76015

統計情報を利用した背景モデルを用いる手法で局所的な明るさ変動が動体として誤検出される問題は、カメラでの明るさの補正を行わないようにすることにより、短期間の間は回避することができる。しかしながら、昼夜を通してカメラを稼働させた場合等、長時間に亘って動体の検出を行う場合は、明るさの補正を行わない状態では画像の明るさが大きく変化し、正常な画像を取得することができなくなる。この結果、動体検出が困難になるという問題がある。   The problem that local brightness fluctuations are erroneously detected as moving objects by using a background model that uses statistical information is avoided for a short period of time by not correcting the brightness of the camera. be able to. However, when moving objects are detected for a long period of time, such as when the camera is operated throughout the day and night, the brightness of the image changes greatly when the brightness is not corrected, and a normal image is acquired. Can not be. As a result, there is a problem that it is difficult to detect moving objects.

本発明は、斯かる事情に鑑みてなされたものであって、その目的とするところは、局所的な明るさ変動に起因する誤検出を抑制することができるコンピュータプログラム、動体検出方法及び動体検出装置を提供することにある。   The present invention has been made in view of such circumstances, and an object of the present invention is to provide a computer program, a moving object detection method, and a moving object detection capable of suppressing erroneous detection due to local brightness fluctuations. To provide an apparatus.

本発明に係るコンピュータプログラムは、コンピュータに、画像に写された動体を検出させるコンピュータプログラムにおいて、動体を検出する処理の対象となる処理対象画像を記憶するコンピュータに、前記処理対象画像内の明るさの分布を特定の参照画像内の明るさの分布に合わせる明るさ補正を行う明るさ補正ステップと、明るさ補正を行った後の処理対象画像に対して、動体検出を行うステップとを含む処理を実行させることを特徴とする。   The computer program according to the present invention is a computer program for causing a computer to detect a moving object in an image. In a computer program for storing a processing target image to be processed for detecting a moving object, the brightness in the processing target image is stored. Including a brightness correction step for performing brightness correction to match the distribution of brightness with the brightness distribution in a specific reference image, and a step for performing moving object detection on the processing target image after performing the brightness correction. Is executed.

本発明に係るコンピュータプログラムは、前記明るさ補正ステップは、前記参照画像及び前記処理対象画像に含まれる各画素の明るさの違いに基づいて、前記処理対象画像での各画素の明るさを前記参照画像での各画素の明るさへ変換するように、各画素の色を表す複数の数値を補正するための補正関数を画素別に生成する補正関数生成ステップと、前記処理対象画像に含まれる各画素の色を表す複数の数値から、各画素について生成した前記補正関数により、明るさが補正された色を表す複数の数値を計算するステップとを含むことを特徴とする。   In the computer program according to the present invention, in the brightness correction step, the brightness of each pixel in the processing target image is determined based on a difference in brightness of each pixel included in the reference image and the processing target image. A correction function generating step for generating, for each pixel, a correction function for correcting a plurality of numerical values representing the color of each pixel so as to convert to the brightness of each pixel in the reference image; and each of the processing target images And calculating a plurality of numerical values representing colors whose brightness has been corrected by the correction function generated for each pixel from a plurality of numerical values representing the color of the pixel.

本発明に係るコンピュータプログラムは、前記補正関数生成ステップは、前記処理対象画像に含まれる各画素のグレースケール値にエッジ保存平滑化を施した平滑化グレースケール値を計算するステップと、前記参照画像及び前記処理対象画像に含まれる各画素の平滑化グレースケール値の比を、前記参照画像での平滑化グレースケール値を前記処理対象画像での平滑化グレースケール値で除算することによって計算するステップと、前記比が1以下である画素について、前記処理対象画像での色を表す各数値をinputlmg(x,y)、明るさが補正された色を表す各数値をoutputlmg(x,y)、前記比をratio(x、y)として、outputlmg(x,y)=inputlmg(x,y)*ratio(x、y)で表される前記補正関数を生成するステップと、前記比が1を超過する画素について、前記参照画像での平滑化グレースケール値をreferenceMap(x,y)、前記処理対象画像での平滑化グレースケール値をinputMap(x,y)、色を表す各数値が取り得る最大値をmaxとして、outputlmg(x,y)=inputlmg(x,y)*rate+offset、rate=(max−referenceMap(x,y))/(max−inputMap(x,y))、及びoffset=referenceMap(x,y)−rate*inputMap(x,y)で表される前記補正関数を生成するステップとを含むことを特徴とする。   In the computer program according to the present invention, the correction function generating step calculates a smoothed grayscale value obtained by performing edge preserving smoothing on a grayscale value of each pixel included in the processing target image; and the reference image And a ratio of smoothed grayscale values of each pixel included in the processing target image by dividing the smoothed grayscale value in the reference image by the smoothing grayscale value in the processing target image And for each pixel whose ratio is 1 or less, each numerical value representing the color in the processing target image is inputmg (x, y), each numerical value representing the color whose brightness is corrected is outputlmg (x, y), When the ratio is ratio (x, y), output mg (x, y) = input mg (x, y) * ratio (x, y) A step of generating the correction function represented, and a smoothed grayscale value in the reference image as a reference grayscale value in the reference image and a smoothed grayscale in the processing target image with respect to the pixels whose ratio exceeds 1 The value is inputMap (x, y), and the maximum value that each numerical value representing the color can take is max. Outputmg (x, y) = inputlmg (x, y) * rate + offset, rate = (max−referenceMap (x, y) ) / (Max-inputMap (x, y)) and generating the correction function represented by offset = referenceMap (x, y) -rate * inputMap (x, y). .

本発明に係るコンピュータプログラムは、前記参照画像は、統計情報を利用した背景モデルを用いた背景差分により特定されることを特徴とする。   The computer program according to the present invention is characterized in that the reference image is specified by a background difference using a background model using statistical information.

本発明に係る動体検出方法は、演算部及び記憶部を備えるコンピュータにより、画像に写された動体を検出する動体検出方法において、動体を検出する処理の対象となる処理対象画像を前記記憶部に記憶するステップと、前記処理対象画像内の明るさの分布を特定の参照画像内の明るさの分布に合わせる明るさ補正を行うステップと、明るさ補正を行った後の処理対象画像に対して、動体検出を行うステップとを含むことを特徴とする。   A moving object detection method according to the present invention is a moving object detection method in which a computer including a calculation unit and a storage unit detects a moving object copied in an image. In the moving object detection method, a processing target image to be processed is detected in the storage unit. A step of storing, a step of performing a brightness correction to match a brightness distribution in the processing target image with a brightness distribution in a specific reference image, and a processing target image after performing the brightness correction And moving object detection.

本発明に係る動体検出装置は、画像に写された動体を検出する動体検出装置において、動体を検出する処理の対象となる処理対象画像を記憶する記憶部と、前記処理対象画像内の明るさの分布を特定の参照画像内の明るさの分布に合わせる明るさ補正を行う明るさ補正部と、明るさ補正を行った後の処理対象画像に対して、動体検出を行う動体検出部とを備えることを特徴とする。   The moving object detection device according to the present invention is a moving object detection device that detects a moving object that is captured in an image, and a storage unit that stores a processing target image that is a target of processing for detecting the moving object, and brightness within the processing target image. A brightness correction unit that performs brightness correction that matches the distribution of brightness with a brightness distribution in a specific reference image, and a moving object detection unit that performs moving object detection on the processing target image after performing the brightness correction. It is characterized by providing.

本発明においては、動体検出装置は、処理対象画像に対して、明るさの分布を特定の参照画像内の明るさの分布に合わせる明るさ補正を行い、その後に動体検出を行う。局所的な明るさの変化が減少した処理対象画像から動体検出を行うことによって、局所的な明るさ変動が動体として誤検出されることが抑制される。   In the present invention, the moving object detection device performs brightness correction on the processing target image to match the brightness distribution with the brightness distribution in a specific reference image, and then performs moving object detection. By performing the moving object detection from the processing target image in which the local brightness change is reduced, it is possible to suppress the erroneous detection of the local brightness fluctuation as the moving object.

また、本発明においては、動体検出装置は、明るさ補正を行う際に、参照画像及び処理対象画像に含まれる各画素の明るさの違いに基づいて、各画素の色を表す複数の数値を補正するための補正関数を画素別に生成し、補正関数を用いて、各画素の色を表す複数の数値を補正する。画素別に、参照画像及び処理対象画像の明るさの違いに基づいて画素の色が補正されることにより、明るさの分布を参照画像に合わせるように処理対象画像内の明るさの分布が補正される。   Further, in the present invention, when performing the brightness correction, the moving object detection device calculates a plurality of numerical values representing the color of each pixel based on the difference in brightness of each pixel included in the reference image and the processing target image. A correction function for correction is generated for each pixel, and a plurality of numerical values representing the color of each pixel are corrected using the correction function. For each pixel, the brightness distribution in the processing target image is corrected so that the brightness distribution matches the reference image by correcting the color of the pixel based on the difference in brightness between the reference image and the processing target image. The

また、本発明においては、動体検出装置は、補正関数を生成する際に、各画素のグレースケール値にエッジ保存平滑化を施した平滑化グレースケール値を計算し、参照画像及び処理対象画像の平滑化グレースケール値の比を計算し、計算した比が1以下であるか又は1を超過するかに応じて、画素別に補正関数を生成する。エッジ保存平滑化により、ノイズが除去される。平滑化グレースケール値の比が1を超過する場合でも補正関数が線形になるように、平滑化グレースケール値の比の値に応じて補正関数を分けて生成することにより、明るさ補正による白飛びの発生が防止される。   Further, in the present invention, when generating the correction function, the moving object detection device calculates a smoothed grayscale value obtained by performing edge preserving smoothing on the grayscale value of each pixel, and calculates the reference image and the processing target image. A ratio of the smoothed gray scale values is calculated, and a correction function is generated for each pixel depending on whether the calculated ratio is 1 or less or exceeds 1. Noise is removed by edge preserving smoothing. Even when the ratio of the smoothed gray scale value exceeds 1, the correction function is generated separately according to the value of the smoothed gray scale value ratio so that the correction function is linear. The occurrence of flying is prevented.

また、本発明においては、動体検出装置は、動画に含まれる画像の中から、統計情報を利用した背景モデルを用いた背景差分による差分値に基づいて、初期の動体が含まれていない基準画像となる参照画像を特定することができる。   Further, in the present invention, the moving object detection device includes a reference image that does not include an initial moving object based on a difference value based on a background difference using a background model that uses statistical information from among images included in a moving image. Can be identified.

本発明にあっては、動体の誤検出が確実に減少し、また、長時間に亘って動体の検出を行う場合であっても動体検出を継続することが可能となる等、優れた効果を奏する。   In the present invention, it is possible to reliably reduce the false detection of moving objects, and to provide excellent effects such as enabling the detection of moving objects even when moving objects are detected over a long period of time. Play.

画像を撮影し、撮影画像から動体検出を行うカメラシステムの構成例を示す模式図である。It is a schematic diagram which shows the structural example of the camera system which image | photographs an image and detects a moving body from a picked-up image. 動体検出装置の機能構成を示す機能ブロック図である。It is a functional block diagram which shows the function structure of a moving body detection apparatus. 動体検出装置の構成例を示すブロック図である。It is a block diagram which shows the structural example of a moving body detection apparatus. 動体検出装置が実行する処理の手順を示すフローチャートである。It is a flowchart which shows the procedure of the process which a moving body detection apparatus performs. S3の明るさ補正の処理の詳細な手順を示すフローチャートである。It is a flowchart which shows the detailed procedure of the brightness correction process of S3. 参照画像の例を示す模式図である。It is a schematic diagram which shows the example of a reference image. 入力画像の例を示す模式図である。It is a schematic diagram which shows the example of an input image. 補正関数の例を示す特性図である。It is a characteristic view which shows the example of a correction function. 補正関数の例を示す特性図である。It is a characteristic view which shows the example of a correction function. S4の動体検出の処理の詳細な手順を示すフローチャートである。It is a flowchart which shows the detailed procedure of the process of a moving body detection of S4. 動体を写した入力画像の例を示す模式図である。It is a schematic diagram which shows the example of the input image which copied the moving body. 動体の検出例を示す模式図である。It is a schematic diagram which shows the example of a detection of a moving body. 動体の検出例を示す模式図である。It is a schematic diagram which shows the example of a detection of a moving body.

以下本発明をその実施の形態を示す図面に基づき具体的に説明する。
図1は、画像を撮影し、撮影画像から動体検出を行うカメラシステムの構成例を示す模式図である。カメラシステムは、撮影を行うカメラ2と、動体検出を行う動体検出装置1とを備えている。カメラ2は動体検出装置1に接続されている。例えば、カメラ2は監視カメラである。カメラ2は、カメラ2の外部を連続的に撮影した動画、又はカメラ2の外部を繰り返し撮影した複数の静止画の形で画像を作成し、作成した画像を動体検出装置1へ入力する。
Hereinafter, the present invention will be specifically described with reference to the drawings showing embodiments thereof.
FIG. 1 is a schematic diagram illustrating a configuration example of a camera system that captures an image and detects a moving object from the captured image. The camera system includes a camera 2 that performs photographing and a moving object detection device 1 that performs moving object detection. The camera 2 is connected to the moving object detection apparatus 1. For example, the camera 2 is a surveillance camera. The camera 2 creates an image in the form of a moving image obtained by continuously photographing the outside of the camera 2 or a plurality of still images obtained by repeatedly photographing the outside of the camera 2, and inputs the created images to the moving object detection device 1.

図2は、動体検出装置1の機能構成を示す機能ブロック図である。動体検出装置1は、情報処理を行う処理部11と、インタフェース部14と、記憶部15とを備えている。インタフェース部14は、カメラ2に接続されている。カメラ2から入力された画像は、インタフェース部14で受け付けられ、記憶部15に記憶される。画像はビットマップデータ等の所定のフォーマットの電子データとしてカメラ2で作成され、記憶部15に記憶される。画像は複数の画素から構成されており、画像を表す電子データには、各画素の色を表す複数の数値である画素値が含まれている。例えば、各画素の色は、R(赤)G(緑)B(青)夫々の明度の組み合わせで表されている。記憶部15には、少なくとも、動体検出のために参照される参照画像151と、カメラ2から入力された入力画像152とが記憶される。入力画像152は、処理対象画像に対応する。   FIG. 2 is a functional block diagram showing a functional configuration of the moving object detection apparatus 1. The moving object detection apparatus 1 includes a processing unit 11 that performs information processing, an interface unit 14, and a storage unit 15. The interface unit 14 is connected to the camera 2. An image input from the camera 2 is received by the interface unit 14 and stored in the storage unit 15. The image is created by the camera 2 as electronic data of a predetermined format such as bitmap data and stored in the storage unit 15. The image is composed of a plurality of pixels, and the electronic data representing the image includes pixel values that are a plurality of numerical values representing the color of each pixel. For example, the color of each pixel is represented by a combination of lightness values of R (red), G (green), and B (blue). The storage unit 15 stores at least a reference image 151 referred to for moving object detection and an input image 152 input from the camera 2. The input image 152 corresponds to the processing target image.

処理部11は、画像の明るさ補正を行う明るさ補正部12と、明るさ補正された画像から動体を検出する動体検出部13とを備えている。明るさ補正部12は、画像のグレースケール値を計算するグレースケール値計算部121と、グレースケール値の平滑化を行う平滑化部122と、参照画像151と入力画像152との間でグレースケール値を比較する比較部123と、明るさを補正するための補正関数を生成する補正関数生成部124と、明るさ補正の計算を行う補正計算部125とを有している。動体検出部13は、背景モデル生成部131と、入力画像152から動体の候補を検出する動体候補検出部132と、動体の候補の中から動体を特定する動体特定部133とを有している。   The processing unit 11 includes a brightness correction unit 12 that performs image brightness correction, and a moving object detection unit 13 that detects a moving object from the brightness-corrected image. The brightness correction unit 12 includes a grayscale value calculation unit 121 that calculates a grayscale value of an image, a smoothing unit 122 that performs smoothing of the grayscale value, and a grayscale between the reference image 151 and the input image 152. A comparison unit 123 that compares values, a correction function generation unit 124 that generates a correction function for correcting brightness, and a correction calculation unit 125 that calculates brightness correction are included. The moving object detection unit 13 includes a background model generation unit 131, a moving object candidate detection unit 132 that detects a moving object candidate from the input image 152, and a moving object specification unit 133 that specifies a moving object from the moving object candidates. .

動体検出装置1は、サーバ装置又はパーソナルコンピュータ等のコンピュータで構成されている。図3は、動体検出装置1の構成例を示すブロック図である。動体検出装置1は、演算を行うCPU(Central Processing Unit )101と、RAM(Random Access Memory)102と、光ディスク等の記録媒体3から情報を読み取るドライブ部103と、不揮発性記憶部104と、インタフェース部14とを備えている。CPU101は演算部に対応する。例えば、不揮発性記憶部104はハードディスク又は不揮発性の半導体メモリである。CPU101は、記録媒体3に記録されたコンピュータプログラム31をドライブ部103に読み取らせ、読み取ったコンピュータプログラム31を不揮発性記憶部104に記憶させる。コンピュータプログラム31は、動体検出装置1の外部からダウンロードされてもよく、予め不揮発性記憶部104に記憶されていてもよい。CPU101は、必要に応じてコンピュータプログラム31を不揮発性記憶部104からRAM102へロードし、ロードしたコンピュータプログラム31に従って、各種の処理を実行する。CPU101がコンピュータプログラム31に従った処理を実行することにより、処理部11が実現される。記憶部15は、RAM102及び不揮発性記憶部104から構成される。図中には、参照画像151及び入力画像152が不揮発性記憶部104に記憶された例を示したが、参照画像151及び入力画像152はRAM102に記憶されてもよい。なお、処理部11の一部又は全部は、ソフトウェアを用いた処理によって実現されるのではなく、ハードウェアによって構成されていてもよい。   The moving object detection device 1 is configured by a computer such as a server device or a personal computer. FIG. 3 is a block diagram illustrating a configuration example of the moving object detection apparatus 1. The moving object detection apparatus 1 includes a CPU (Central Processing Unit) 101 that performs calculation, a RAM (Random Access Memory) 102, a drive unit 103 that reads information from a recording medium 3 such as an optical disk, a nonvolatile storage unit 104, an interface Part 14. The CPU 101 corresponds to a calculation unit. For example, the non-volatile storage unit 104 is a hard disk or a non-volatile semiconductor memory. The CPU 101 causes the drive unit 103 to read the computer program 31 recorded on the recording medium 3 and stores the read computer program 31 in the nonvolatile storage unit 104. The computer program 31 may be downloaded from the outside of the moving object detection device 1 or may be stored in advance in the nonvolatile storage unit 104. The CPU 101 loads the computer program 31 from the nonvolatile storage unit 104 to the RAM 102 as necessary, and executes various processes according to the loaded computer program 31. The processing unit 11 is realized when the CPU 101 executes processing according to the computer program 31. The storage unit 15 includes a RAM 102 and a nonvolatile storage unit 104. In the figure, an example in which the reference image 151 and the input image 152 are stored in the nonvolatile storage unit 104 is shown, but the reference image 151 and the input image 152 may be stored in the RAM 102. Note that part or all of the processing unit 11 may not be realized by processing using software, but may be configured by hardware.

以下に、動体検出装置1の動作を説明する。図4は、動体検出装置1が実行する処理の手順を示すフローチャートである。CPU101は、コンピュータプログラム31に基づいて以下の処理を実行する。カメラ2から動体検出装置1へ画像が入力され(S1)、動体検出装置1は、参照画像151、及びカメラ2から入力された入力画像152を記憶部15に記憶する(S2)。カメラ2から入力される画像は、カメラ2で撮影された動画の最新の部分、又はカメラ2で撮影された最新の静止画である。参照画像151は、背景のみが写されていると期待され得る画像である。例えば、参照画像151は、カメラ2で撮影された動画の最初の1フレームの画像、又は予め作成された画像である。入力画像152は、例えば、入力された動画に含まれる1フレームの画像、又は入力された静止画である。S1では、CPU101は、入力画像152を不揮発性記憶部104及びRAM102に記憶し、予め不揮発性記憶部104に記憶されている参照画像151を読み出してRAM102に記憶する。CPU101は、入力画像152内の明るさの分布を参照画像151内の明るさの分布に合わせるように入力画像152の明るさ補正を行い(S3)、次に、明るさ補正を行った後の入力画像152から動体検出を行う(S4)。S3の明るさ補正の処理は明るさ補正部12に対応し、S4の動体検出の処理は動体検出部13に対応する。   Below, operation | movement of the moving body detection apparatus 1 is demonstrated. FIG. 4 is a flowchart illustrating a procedure of processing executed by the moving object detection apparatus 1. The CPU 101 executes the following processing based on the computer program 31. An image is input from the camera 2 to the moving object detection apparatus 1 (S1), and the moving object detection apparatus 1 stores the reference image 151 and the input image 152 input from the camera 2 in the storage unit 15 (S2). The image input from the camera 2 is the latest part of the moving image captured by the camera 2 or the latest still image captured by the camera 2. The reference image 151 is an image that can be expected to include only the background. For example, the reference image 151 is an image of the first frame of a moving image shot by the camera 2 or an image created in advance. The input image 152 is, for example, one frame image included in the input moving image or an input still image. In S <b> 1, the CPU 101 stores the input image 152 in the nonvolatile storage unit 104 and the RAM 102, reads the reference image 151 stored in advance in the nonvolatile storage unit 104, and stores the reference image 151 in the RAM 102. The CPU 101 corrects the brightness of the input image 152 so that the brightness distribution in the input image 152 matches the brightness distribution in the reference image 151 (S3), and then the brightness correction is performed. A moving object is detected from the input image 152 (S4). The brightness correction process in S3 corresponds to the brightness correction unit 12, and the moving object detection process in S4 corresponds to the moving object detection unit 13.

図5は、S3の明るさ補正の処理の詳細な手順を示すフローチャートである。図6は、参照画像151の例を示す模式図であり、図7は、入力画像152の例を示す模式図である。図6に示す参照画像151及び図7に示す入力画像152は、同じ室内を撮影した画像である。図6に示す参照画像151に比べて、図7に示す入力画像152では局所的に明るさが変動している。CPU101は、入力画像152に含まれる各画素のグレースケール値を計算する(S31)。グレースケール値は、各画素の明暗を表す値である。グレースケール値が8ビットで表される場合は、グレースケール値は0〜255のいずれかの値となる。グレースケール値は、各画素の色を表す複数の画素値から所定の方法で計算される。例えば、CPU101は、画素毎に記録されているRGBの明度の値から、所定の計算式を用いてグレースケール値を計算する。   FIG. 5 is a flowchart showing a detailed procedure of the brightness correction process in S3. FIG. 6 is a schematic diagram illustrating an example of the reference image 151, and FIG. 7 is a schematic diagram illustrating an example of the input image 152. The reference image 151 shown in FIG. 6 and the input image 152 shown in FIG. 7 are images taken of the same room. Compared to the reference image 151 shown in FIG. 6, the brightness locally fluctuates in the input image 152 shown in FIG. 7. The CPU 101 calculates the gray scale value of each pixel included in the input image 152 (S31). The gray scale value is a value representing the brightness of each pixel. When the gray scale value is represented by 8 bits, the gray scale value is any value from 0 to 255. The gray scale value is calculated by a predetermined method from a plurality of pixel values representing the color of each pixel. For example, the CPU 101 calculates a gray scale value using a predetermined calculation formula from the RGB brightness values recorded for each pixel.

CPU101は、次に、入力画像152の各画素のグレースケール値に対して、エッジ保存平滑化を行う(S32)。入力画像152の各画素のグレースケール値にエッジ保存平滑化を施した平滑化グレースケール値が計算される。CPU101は、所定のフィルタを用いて、エッジ保存平滑化の計算を行う。エッジ保存平滑化により、入力画像152内のエッジが保存されながらも、明るさの分布が平滑化され、ノイズが除去される。参照画像151の各画素の平滑化グレースケール値は、予め計算されて不揮発性記憶部104に記憶されている。CPU101は、参照画像151の各画素の平滑化グレースケール値を不揮発性記憶部104から読み出してRAM102に記憶する。なお、CPU101は、S31で参照画像151の各画素のグレースケール値をも計算し、S32で参照画像151の各画素の平滑化グレースケール値をも計算してもよい。   Next, the CPU 101 performs edge preserving smoothing on the gray scale value of each pixel of the input image 152 (S32). A smoothed gray scale value obtained by performing edge preserving smoothing on the gray scale value of each pixel of the input image 152 is calculated. The CPU 101 performs edge preserving smoothing calculation using a predetermined filter. The edge preserving smoothing smoothes the brightness distribution and removes noise while preserving the edges in the input image 152. The smoothed gray scale value of each pixel of the reference image 151 is calculated in advance and stored in the nonvolatile storage unit 104. The CPU 101 reads the smoothed gray scale value of each pixel of the reference image 151 from the nonvolatile storage unit 104 and stores it in the RAM 102. Note that the CPU 101 may also calculate the gray scale value of each pixel of the reference image 151 in S31, and may also calculate the smoothed gray scale value of each pixel of the reference image 151 in S32.

CPU101は、次に、参照画像151及び入力画像152に含まれる各画素の平滑化グレースケール値の比を計算する(S33)。具体的には、参照画像151の平滑化グレースケール値を入力画像152の平滑化グレースケール値で除算した値を計算する。画像内での画素の位置を(x,y)で表し、参照画像151の平滑化グレースケール値をreferenceMap(x,y)とし、入力画像152の平滑化グレースケール値をinputMap(x,y)とする。計算される比の値ratio(x、y)は、ratio(x、y)=referenceMap(x,y)/inputMap(x,y)である。   Next, the CPU 101 calculates the ratio of the smoothed gray scale values of the pixels included in the reference image 151 and the input image 152 (S33). Specifically, a value obtained by dividing the smoothed grayscale value of the reference image 151 by the smoothed grayscale value of the input image 152 is calculated. The pixel position in the image is represented by (x, y), the smoothed grayscale value of the reference image 151 is referred to as referenceMap (x, y), and the smoothed grayscale value of the input image 152 is inputMap (x, y). And The calculated ratio value ratio (x, y) is ratio (x, y) = referenceMap (x, y) / inputMap (x, y).

CPU101は、次に、入力画像152に含まれる複数の画素から一の画素を選択する(S34)。CPU101は、次に、選択した画素についてS33で計算した平滑化グレースケール値の比ratio(x、y)が1以下であるか否かを判定する(S35)。平滑化グレースケール値の比が1以下である場合(S35:YES)、CPU101は、平滑化グレースケール値の比が1以下であることに応じた、画素の色を補正するための補正関数を生成する(S36)。入力画像152での画素値をinputlmg(x,y)とし、補正後の画素値をoutputlmg(x,y)とする。平滑化グレースケール値の比が1以下である場合の補正関数は、inputlmg(x,y)=0、outputlmg(x,y)=0とした二次元座標系上の点(0,0)と、inputlmg(x,y)=inputMap(x,y)、outputlmg(x,y)=referenceMap(x,y)とした点(inputMap(x,y),referenceMap(x,y))とを通る線形関数とする。S36では、CPU101は、下記の(1)式で表される補正関数を生成する。
outputlmg(x,y)=inputlmg(x,y)*ratio(x、y) …(1)
Next, the CPU 101 selects one pixel from a plurality of pixels included in the input image 152 (S34). Next, the CPU 101 determines whether or not the ratio ratio (x, y) of the smoothed grayscale values calculated in S33 for the selected pixel is 1 or less (S35). When the ratio of the smoothed gray scale value is 1 or less (S35: YES), the CPU 101 calculates a correction function for correcting the color of the pixel according to the ratio of the smoothed gray scale value being 1 or less. Generate (S36). The pixel value in the input image 152 is set as inputmg (x, y), and the corrected pixel value is set as outputmg (x, y). The correction function when the ratio of the smoothed gray scale values is 1 or less is a point (0, 0) on the two-dimensional coordinate system where input mg (x, y) = 0 and output mg (x, y) = 0. , Inputmg (x, y) = inputMap (x, y), outputmg (x, y) = referenceMap (x, y) and a line passing through a point (inputMap (x, y), referenceMap (x, y)) Let it be a function. In S36, the CPU 101 generates a correction function represented by the following equation (1).
outputlmg (x, y) = inputlmg (x, y) * ratio (x, y) (1)

平滑化グレースケール値の比ratio(x,y)が1を超過する場合(S35:NO)、CPU101は、平滑化グレースケール値の比が1を超過することに応じた補正関数を生成する(S37)。画素値が取り得る最大値をmaxとする。平滑化グレースケール値の比が1を超過する場合の補正関数は、点(inputMap(x,y),referenceMap(x,y))と、inputlmg(x,y)=max、outputlmg(x,y)=maxとした点(max,max)とを通る線形関数とする。画素値が8ビットで表される場合は、max=255となる。S37では、CPU101は、下記の(2)式〜(4)式で表される補正関数を生成する。
outputlmg(x,y)=inputlmg(x,y)*rate+offset …(2)
rate=(max−referenceMap(x,y))/(max−inputMap(x,y)) …(3)
offset=referenceMap(x,y)−rate*inputMap(x,y) …(4)
When the ratio ratio (x, y) of the smoothed gray scale value exceeds 1 (S35: NO), the CPU 101 generates a correction function corresponding to the ratio of the smoothed gray scale value exceeding 1 ( S37). The maximum value that the pixel value can take is assumed to be max. The correction function when the ratio of the smoothed gray scale values exceeds 1 is a point (inputMap (x, y), referenceMap (x, y)), inputlmg (x, y) = max, outputlmg (x, y ) = A linear function passing through a point (max, max). When the pixel value is represented by 8 bits, max = 255. In S37, the CPU 101 generates a correction function represented by the following equations (2) to (4).
outputmg (x, y) = inputmg (x, y) * rate + offset (2)
rate = (max-referenceMap (x, y)) / (max-inputMap (x, y)) (3)
offset = referenceMap (x, y) -rate * inputMap (x, y) (4)

図8及び図9は、補正関数の例を示す特性図である。図8は、平滑化グレースケール値の比ratio(x、y)が1以下の場合の補正関数を示し、図9は、平滑化グレースケール値の比が1を超過する場合の補正関数を示す。図8及び図9には、補正関数を実線で示し、二次元座標系上の点(0,0)及び(max,max)を結ぶ傾き1の直線を破線で示している。平滑化グレースケール値の比が1以下の場合でも、1を超過する場合でも、補正関数は線形関数であり、(inputMap(x,y),referenceMap(x,y))を通る。また、補正関数の傾きは1以下になっている。平滑化グレースケール値の比が1である場合に、補正関数の傾きは1となる。何れの補正関数も、入力画像152での画素の明るさを参照画像151での明るさに合わせるように画素値を補正するための関数になっている。   8 and 9 are characteristic diagrams showing examples of the correction function. FIG. 8 shows a correction function when the ratio ratio (x, y) of the smoothed gray scale values is 1 or less, and FIG. 9 shows a correction function when the ratio of the smoothed gray scale values exceeds 1. . In FIGS. 8 and 9, the correction function is indicated by a solid line, and a straight line having a slope 1 connecting points (0, 0) and (max, max) on the two-dimensional coordinate system is indicated by a broken line. Whether the ratio of the smoothed gray scale values is 1 or less or exceeds 1, the correction function is a linear function and passes through (inputMap (x, y), referenceMap (x, y)). Further, the inclination of the correction function is 1 or less. When the ratio of the smoothed gray scale values is 1, the slope of the correction function is 1. Each of the correction functions is a function for correcting the pixel value so that the brightness of the pixel in the input image 152 matches the brightness in the reference image 151.

平滑化グレースケール値の比が1を超過する場合は、補正関数を(1)式のように点(0,0)を通る線形関数にすると、補正前の値inputlmg(x,y)がmaxに達しない内に補正後の値outputlmg(x,y)がmaxに達するようになる。即ち、補正関数は非線形となり、明るさ補正によって白飛びが発生する虞がある。図9に示す如く、平滑化グレースケール値の比が1を超過する場合でも補正関数が線形になるように、平滑化グレースケール値の比の値に応じて補正関数を分けて生成することにより、明るさ補正による白飛びの発生が防止される。   When the ratio of the smoothed gray scale values exceeds 1, if the correction function is a linear function passing through the point (0, 0) as shown in the equation (1), the value inputmg (x, y) before correction is max. The corrected value outputlmg (x, y) reaches max before the value reaches the maximum value. That is, the correction function becomes non-linear, and there is a possibility that whiteout occurs due to brightness correction. As shown in FIG. 9, by generating the correction function separately according to the value of the smoothed grayscale value ratio so that the correction function becomes linear even when the ratio of the smoothed grayscale value exceeds 1. The occurrence of overexposure due to brightness correction is prevented.

S36又はS37が終了した後は、CPU101は、生成した補正関数を用いて、入力画像152での画素値から、明るさが補正された色を表す画素値を計算する(S38)。S38では、CPU101は、補正関数中のinputlmg(x,y)に画素値を代入し、補正後の画素値outputlmg(x,y)を計算する。画素の色を表す複数の画素値の夫々について、同一の補正関数を用いて、補正後の画素値outputlmg(x,y)が計算される。例えば、RGBの明度の値の夫々について、同一の補正関数により、明るさが補正された明度の値が計算される。なお、画素の色を表す複数の画素値が取り得る範囲が異なる場合は、(3)式中のmaxの値を画素値が取り得る範囲に応じた値にしてその他は同一な補正関数により、補正後の画素値が計算される。S38により、入力画像152での画素の明るさを参照画像151での明るさに合わせるように画素の色を表す各画素値が補正される。CPU101は、計算した補正後の各画素値を記憶部15に記憶する。   After S <b> 36 or S <b> 37 ends, the CPU 101 calculates a pixel value representing a color whose brightness has been corrected from the pixel value in the input image 152 using the generated correction function (S <b> 38). In S38, the CPU 101 substitutes the pixel value for inputmg (x, y) in the correction function, and calculates the corrected pixel value outputlmg (x, y). The corrected pixel value outputlmg (x, y) is calculated for each of a plurality of pixel values representing the color of the pixel using the same correction function. For example, for each of the RGB brightness values, the brightness value with the brightness corrected is calculated by the same correction function. If the ranges that can be taken by a plurality of pixel values representing the color of the pixel are different, the value of max in the equation (3) is set to a value corresponding to the range that the pixel value can take, and the rest is the same correction function. The corrected pixel value is calculated. Through S38, each pixel value representing the color of the pixel is corrected so that the brightness of the pixel in the input image 152 matches the brightness in the reference image 151. The CPU 101 stores the calculated pixel values after correction in the storage unit 15.

CPU101は、次に、S34〜S38の処理が未処理の画素があるか否かを判定する(S39)。未処理の画素がある場合は(S39:YES)、CPU101は、処理をS34へ戻し、未処理の画素の中から一の画素を選択する。入力画像152内の全ての画素について補正後の色を表す画素値が計算されることにより、入力画像152内の明るさの分布を参照画像151内の明るさの分布に合わせるように明るさ補正が行われる。入力画像152内の全ての画素について補正後の画素値が記憶されることにより、明るさ補正された入力画像152が記憶部15に記憶される。未処理の画素が無い場合は(S39:NO)、CPU101は、S3の明るさ補正の処理を終了する。なお、CPU101は、一旦各画素について補正関数を生成してから、各画素について補正後の画素値を計算する処理を行ってもよい。S31の処理はグレースケール値計算部121に対応し、S32の処理は平滑化部122に対応し、S33の処理は比較部に対応し、S34〜S37の処理は補正関数生成部124に対応し、S38の処理は補正計算部125に対応する。   Next, the CPU 101 determines whether or not there is a pixel that has not been processed in S34 to S38 (S39). If there is an unprocessed pixel (S39: YES), the CPU 101 returns the process to S34 and selects one pixel from the unprocessed pixels. Brightness correction is performed so that the brightness distribution in the input image 152 matches the brightness distribution in the reference image 151 by calculating pixel values representing corrected colors for all pixels in the input image 152. Is done. By storing the corrected pixel values for all the pixels in the input image 152, the brightness-corrected input image 152 is stored in the storage unit 15. If there is no unprocessed pixel (S39: NO), the CPU 101 ends the brightness correction process in S3. Note that the CPU 101 may generate a correction function for each pixel and then perform a process of calculating a corrected pixel value for each pixel. The processing of S31 corresponds to the gray scale value calculation unit 121, the processing of S32 corresponds to the smoothing unit 122, the processing of S33 corresponds to the comparison unit, and the processing of S34 to S37 corresponds to the correction function generation unit 124. , S38 corresponds to the correction calculation unit 125.

図10は、S4の動体検出の処理の詳細な手順を示すフローチャートである。図11は、動体を写した入力画像152の例を示す模式図である。図11に示す入力画像152には、図6に示す参照画像151に写された背景に加えて、人である動体が写っている。CPU101は、明るさ補正が行われた画像に基づき、統計情報を利用した背景モデリングにより、背景差分に用いるための背景モデルを生成する(S41)。不揮発性記憶部104には、背景を写しており明るさ補正が行われた複数の画像が記憶されており、CPU101は、これらの複数の画像を読み出し、読み出した複数の画像に基づいて、統計情報を利用した背景モデリングを行う。背景モデルの基となる複数の画像には、過去に入力され明るさ補正が行われた複数の入力画像152が含まれる。背景モデルの基となる複数の画像には、参照画像151が含まれていてもよい。例えば、CPU101は、明るさ補正が行われた過去の入力画像152中で背景に対応する部分の画素値の変動を統計処理して、背景モデルを生成する。なお、S41では、CPU101は、予め生成されて記憶されている背景モデルを読み出してもよく、予め生成されている背景モデルを更新してもよい。   FIG. 10 is a flowchart showing a detailed procedure of the moving object detection process of S4. FIG. 11 is a schematic diagram illustrating an example of the input image 152 in which a moving object is copied. The input image 152 shown in FIG. 11 shows a moving object that is a person in addition to the background shown in the reference image 151 shown in FIG. The CPU 101 generates a background model to be used for the background difference by background modeling using statistical information based on the image subjected to brightness correction (S41). The non-volatile storage unit 104 stores a plurality of images in which the background is copied and the brightness is corrected. The CPU 101 reads out the plurality of images, and based on the read out plurality of images, the statistical information is stored. Perform background modeling using information. The plurality of images that are the basis of the background model include a plurality of input images 152 that have been input in the past and subjected to brightness correction. The reference image 151 may be included in the plurality of images that are the basis of the background model. For example, the CPU 101 generates a background model by statistically processing changes in pixel values of a portion corresponding to the background in the past input image 152 that has been subjected to brightness correction. In S41, the CPU 101 may read a background model generated and stored in advance, or may update a background model generated in advance.

CPU101は、次に、背景差分により、明るさ補正が行われた入力画像152から動体候補を検出する(S42)。S42では、CPU101は、背景モデルと明るさ補正が行われた入力画像152とを比較し、画素値が背景モデルと異なっている画素を抽出し、抽出した画素が含まれる領域を動体候補として検出する。例えば、CPU101は、背景モデルにおいて画素値の平均及び標準偏差を用いて各画素について定められた許容範囲内に画素値が含まれていない場合に、画素値が背景モデルと異なっているとする。S42では、CPU101は、画素値が背景モデルと異なっている画素を含んだ領域を矩形枠で囲み、入力画像152中で矩形枠で囲んだ領域を動体候補としてラベリングする。S42では、動体候補が検出されないこともあり、複数の動体候補が検出されることもある。   Next, the CPU 101 detects a moving object candidate from the input image 152 on which the brightness correction has been performed based on the background difference (S42). In S42, the CPU 101 compares the background model with the input image 152 subjected to brightness correction, extracts pixels whose pixel values are different from those of the background model, and detects a region including the extracted pixels as a moving object candidate. To do. For example, the CPU 101 determines that the pixel value is different from the background model when the pixel value is not included in the allowable range defined for each pixel using the average and standard deviation of the pixel value in the background model. In S <b> 42, the CPU 101 encloses an area including pixels whose pixel values are different from the background model with a rectangular frame, and labels the area enclosed by the rectangular frame in the input image 152 as a moving object candidate. In S42, moving object candidates may not be detected, and a plurality of moving object candidates may be detected.

CPU101は、次に、動体候補があるか否かを判定する(S43)。動体候補がある場合は(S43:YES)、CPU101は、一の動体候補を選択する(S44)。CPU101は、次に、選択した動体候補の矩形枠の入力画像152内でのサイズが所定範囲内であるか否かを判定する(S45)。矩形枠のサイズの上限値及び下限値が予め定められており、矩形枠のサイズが下限値以上かつ上限値以下である場合に、CPU101は、動体候補の矩形枠のサイズが所定範囲内であると判定する。矩形枠のサイズの上限値及び下限値は、入力画像152に写り得る動体の適切なサイズに合わせて予め定められている。上限値及び下限値は、予め不揮発性記憶部104に記憶されているか、又はコンピュータプログラム31に記録されている。   Next, the CPU 101 determines whether there is a moving object candidate (S43). When there is a moving object candidate (S43: YES), the CPU 101 selects one moving object candidate (S44). Next, the CPU 101 determines whether or not the size of the rectangular frame of the selected moving object candidate in the input image 152 is within a predetermined range (S45). When the upper limit value and the lower limit value of the size of the rectangular frame are determined in advance, and the size of the rectangular frame is not less than the lower limit value and not more than the upper limit value, the CPU 101 determines that the size of the rectangular frame of the moving object candidate is within a predetermined range. Is determined. The upper limit value and the lower limit value of the size of the rectangular frame are determined in advance according to an appropriate size of the moving object that can appear in the input image 152. The upper limit value and the lower limit value are stored in advance in the nonvolatile storage unit 104 or are recorded in the computer program 31.

動体候補の矩形枠のサイズが所定範囲内であった場合は(S45:YES)、CPU101は、入力画像152中で矩形枠に囲まれた領域を動体であると特定する(S46)。CPU101は、動体であると特定した領域を示す情報を入力画像152に関連付けて不揮発性記憶部104に記憶する。動体候補の矩形枠のサイズが所定範囲から外れている場合(S45:NO)、又はS46が終了した後は、CPU101は、処理をS43へ戻し、未処理の動体候補があるか否かを判定する。   When the size of the rectangular frame of the moving object candidate is within the predetermined range (S45: YES), the CPU 101 identifies an area surrounded by the rectangular frame in the input image 152 as a moving object (S46). The CPU 101 stores information indicating the area identified as a moving object in the nonvolatile storage unit 104 in association with the input image 152. When the size of the rectangular frame of the moving object candidate is out of the predetermined range (S45: NO), or after S46 ends, the CPU 101 returns the process to S43 and determines whether there is an unprocessed moving object candidate. To do.

S43で動体候補が無い場合は(S43:NO)、S4の動体検出の処理を終了する。最終的に、動体が全く検出されないこともあり、複数の動体が検出されることもある。S41の処理は背景モデル生成部131に対応し、S42の処理は動体候補検出部132に対応し、S43〜S46の処理は動体特定部133に対応する。なお、CPU101は、S43の処理の後で、背景モデルを更新し、不揮発性記憶部104に記憶してもよい。S4の動体検出の処理が終了した後は、動体検出装置1は処理を終了する。   If there is no moving object candidate in S43 (S43: NO), the moving object detection process in S4 is terminated. Finally, a moving object may not be detected at all, and a plurality of moving objects may be detected. The process of S41 corresponds to the background model generation unit 131, the process of S42 corresponds to the moving object candidate detection unit 132, and the processes of S43 to S46 correspond to the moving object specifying unit 133. Note that the CPU 101 may update the background model and store it in the nonvolatile storage unit 104 after the process of S43. After the moving object detection process of S4 ends, the moving object detection apparatus 1 ends the process.

図12及び図13は、動体の検出例を示す模式図である。図12には、図11に示す入力画像152から明るさ補正を行わずに動体を検出した例を示している。図13には、本実施形態により、図11に示す入力画像152から明るさ補正を行った後に動体を検出した例を示している。図12に示した例では、局所的に明るさが変動した部分が動体として誤検出されている。図13に示した例では、局所的に明るさが変動した部分が誤検出されておらず、画像内に写っている動体が矩形枠に囲まれて特定されている。   12 and 13 are schematic diagrams showing examples of moving object detection. FIG. 12 illustrates an example in which a moving object is detected from the input image 152 illustrated in FIG. 11 without performing brightness correction. FIG. 13 shows an example in which a moving object is detected after performing brightness correction from the input image 152 shown in FIG. 11 according to the present embodiment. In the example shown in FIG. 12, a portion whose brightness has fluctuated locally is erroneously detected as a moving object. In the example shown in FIG. 13, a portion whose brightness has fluctuated locally is not erroneously detected, and the moving object shown in the image is specified by being surrounded by a rectangular frame.

カメラ2から画像が入力される都度、動体検出装置1はS1〜S4の処理を実行する。例えば、カメラ2で撮影された動画の一フレームが入力される都度、動体検出装置1はS1〜S4の処理を実行する。処理で利用される参照画像151は同一であってもよく、時間経過に応じて参照画像151が変更されてもよい。なお、動体検出装置1は、画像が入力される都度処理を実行するのではなく、その他のタイミングで処理を実行してもよい。例えば、動体検出装置1は、入力された画像を記憶部15に記憶しておき、所定量の画像が記憶された場合、処理の開始の指示を受け付けた場合、又は定期的に、記憶された画像の夫々についてS3及びS4の処理を実行してもよい。   Each time an image is input from the camera 2, the moving object detection device 1 executes the processes of S <b> 1 to S <b> 4. For example, each time a frame of a moving image shot by the camera 2 is input, the moving object detection apparatus 1 executes the processes of S1 to S4. The reference image 151 used in the processing may be the same, and the reference image 151 may be changed as time passes. Note that the moving object detection apparatus 1 may execute the process at other timings instead of executing the process every time an image is input. For example, the moving object detection device 1 stores the input image in the storage unit 15 and is stored when a predetermined amount of image is stored, when an instruction to start processing is received, or periodically. You may perform the process of S3 and S4 about each of an image.

動体検出装置1での動体の検出結果は、他の装置での処理に利用される。例えば、動体が検出された場合に、カメラ2が撮影する動画の録画を開始する処理が行われる。また、例えば、動体が検出された場合に、警報を発する処理が行われる。また、例えば、動体が検出された場合に、接客用ロボットが接客を開始する処理が行われる。   The detection result of the moving object in the moving object detection device 1 is used for processing in another device. For example, when a moving object is detected, a process of starting recording a moving image taken by the camera 2 is performed. In addition, for example, when a moving object is detected, a process for issuing an alarm is performed. Further, for example, when a moving object is detected, a process of starting the customer service by the customer service robot is performed.

以上詳述した如く、本実施形態においては、動体検出装置1は、入力画像152の明るさ補正を行い、その後に背景差分による動体検出を行う。統計情報を利用した背景モデルを用いた背景差分により、局所的な背景の変化に対してロバスト性のある動体検出を行うことができる。即ち、樹木の揺動等の局所的な背景の変化が動体として誤検出されることが抑制される。また、入力画像152内の明るさの分布を参照画像151内の明るさの分布に合わせるように明るさ補正を行うことで、入力画像152内では、参照画像151に比べた局所的な明るさの変化が減少する。局所的な明るさの変化が減少した入力画像152から動体検出を行うことにより、局所的な明るさ変動に対してロバスト性のある動体検出を行うことができる。即ち、局所的な明るさ変動が動体として誤検出されることが抑制される。従って、図13に示すように、動体の誤検出が確実に減少する。   As described above in detail, in the present embodiment, the moving object detection apparatus 1 performs brightness correction on the input image 152 and then performs moving object detection based on background differences. With background difference using a background model using statistical information, it is possible to detect a moving object that is robust against local background changes. That is, it is possible to prevent a local background change such as a tree swing from being erroneously detected as a moving object. Further, by performing brightness correction so that the brightness distribution in the input image 152 matches the brightness distribution in the reference image 151, the local brightness in the input image 152 compared to the reference image 151 is obtained. The change in is reduced. By performing moving object detection from the input image 152 in which the change in local brightness is reduced, it is possible to perform moving object detection that is robust against local brightness fluctuations. That is, erroneous detection of local brightness fluctuations as moving objects is suppressed. Therefore, as shown in FIG. 13, erroneous detection of moving objects is reliably reduced.

局所的な明るさ変動に起因する誤検出が抑制されるので、カメラ2で露出又はホワイトバランス等の調整により明るさの補正を行った場合でも、誤検出が抑制される。このため、長時間に亘って動体の検出を行う場合であっても、正常な画像を取得することが可能となり、動体検出を継続することが可能となる。   Since erroneous detection due to local brightness fluctuations is suppressed, erroneous detection is suppressed even when the camera 2 corrects the brightness by adjusting exposure or white balance. For this reason, even when a moving object is detected over a long period of time, a normal image can be acquired, and the moving object detection can be continued.

なお、本実施形態においては、カメラ2で作成した画像から動体を検出する形態を示したが、動体検出装置1は、カメラでの撮影以外の方法で作成した画像から動体を検出する形態であってもよい。また、動体検出装置1は、動画に含まれる1フレーム目の画像を参照画像151として設定する他に、動画に含まれる全フレームの内で、統計情報を利用した背景モデルを用いた背景差分による差分値が最も小さい画像を、初期の動体が含まれていない基準画像となる参照画像151として特定することも可能である。また、本実施形態においては、カラー画像から動体を検出する形態を示したが、動体検出装置1は、単色画像から動体を検出する形態であってもよい。また、本実施形態においては、動体検出装置1とカメラ2とが分離した形態を示したが、動体検出装置1とカメラ2とは一体であってもよい。例えば、一体となった動体検出装置1及びカメラ2をスマートフォンで構成してもよい。   In the present embodiment, a mode in which a moving object is detected from an image created by the camera 2 is shown. However, the moving object detection device 1 is a mode in which a moving object is detected from an image created by a method other than shooting by the camera. May be. In addition to setting the first frame image included in the moving image as the reference image 151, the moving object detection device 1 uses background difference using a background model using statistical information among all the frames included in the moving image. It is also possible to specify an image having the smallest difference value as a reference image 151 that is a base image that does not include an initial moving object. Moreover, although the form which detects a moving body from a color image was shown in this embodiment, the form which detects a moving body from a monochromatic image may be sufficient as the moving body detection apparatus 1. FIG. In the present embodiment, the moving object detection device 1 and the camera 2 are separated from each other. However, the moving object detection device 1 and the camera 2 may be integrated. For example, you may comprise the moving body detection apparatus 1 and the camera 2 which were united with the smart phone.

1 動体検出装置
101 CPU
102 RAM
104 不揮発性記憶部
11 処理部
12 明るさ補正部
13 動体検出部
15 記憶部
151 参照画像
152 入力画像
2 カメラ
3 記録媒体
31 コンピュータプログラム
1 Moving Object Detection Device 101 CPU
102 RAM
DESCRIPTION OF SYMBOLS 104 Nonvolatile memory | storage part 11 Processing part 12 Brightness correction | amendment part 13 Moving body detection part 15 Memory | storage part 151 Reference image 152 Input image 2 Camera 3 Recording medium 31 Computer program

Claims (6)

コンピュータに、画像に写された動体を検出させるコンピュータプログラムにおいて、
動体を検出する処理の対象となる処理対象画像を記憶するコンピュータに、
前記処理対象画像内の明るさの分布を特定の参照画像内の明るさの分布に合わせる明るさ補正を行う明るさ補正ステップと、
明るさ補正を行った後の処理対象画像に対して、動体検出を行うステップと
を含む処理を実行させることを特徴とするコンピュータプログラム。
In a computer program that causes a computer to detect a moving object in an image,
In a computer that stores a processing target image that is a target of processing for detecting a moving object,
A brightness correction step for performing brightness correction to match the brightness distribution in the processing target image with the brightness distribution in a specific reference image;
A computer program for executing a process including a step of performing moving object detection on a processing target image after performing brightness correction.
前記明るさ補正ステップは、
前記参照画像及び前記処理対象画像に含まれる各画素の明るさの違いに基づいて、前記処理対象画像での各画素の明るさを前記参照画像での各画素の明るさへ変換するように、各画素の色を表す複数の数値を補正するための補正関数を画素別に生成する補正関数生成ステップと、
前記処理対象画像に含まれる各画素の色を表す複数の数値から、各画素について生成した前記補正関数により、明るさが補正された色を表す複数の数値を計算するステップと
を含むことを特徴とする請求項1に記載のコンピュータプログラム。
The brightness correction step includes
Based on the difference in brightness of each pixel included in the reference image and the processing target image, so as to convert the brightness of each pixel in the processing target image to the brightness of each pixel in the reference image, A correction function generation step for generating, for each pixel, a correction function for correcting a plurality of numerical values representing the color of each pixel;
Calculating a plurality of numerical values representing colors whose brightness has been corrected by the correction function generated for each pixel from a plurality of numerical values representing the color of each pixel included in the processing target image. The computer program according to claim 1.
前記補正関数生成ステップは、
前記処理対象画像に含まれる各画素のグレースケール値にエッジ保存平滑化を施した平滑化グレースケール値を計算するステップと、
前記参照画像及び前記処理対象画像に含まれる各画素の平滑化グレースケール値の比を、前記参照画像での平滑化グレースケール値を前記処理対象画像での平滑化グレースケール値で除算することによって計算するステップと、
前記比が1以下である画素について、前記処理対象画像での色を表す各数値をinputlmg(x,y)、明るさが補正された色を表す各数値をoutputlmg(x,y)、前記比をratio(x、y)として、下記の(1)式で表される前記補正関数を生成するステップと、
outputlmg(x,y)=inputlmg(x,y)*ratio(x、y) …(1)
前記比が1を超過する画素について、前記参照画像での平滑化グレースケール値をreferenceMap(x,y)、前記処理対象画像での平滑化グレースケール値をinputMap(x,y)、色を表す各数値が取り得る最大値をmaxとして、下記の(2)式〜(4)式で表される前記補正関数を生成するステップと、
outputlmg(x,y)=inputlmg(x,y)*rate+offset …(2)
rate=(max−referenceMap(x,y))/(max−inputMap(x,y)) …(3)
offset=referenceMap(x,y)−rate*inputMap(x,y) …(4)
を含むことを特徴とする請求項2に記載のコンピュータプログラム。
The correction function generation step includes:
Calculating a smoothed grayscale value obtained by performing edge preservation smoothing on the grayscale value of each pixel included in the processing target image;
By dividing the ratio of the smoothed grayscale value of each pixel included in the reference image and the processing target image by dividing the smoothing grayscale value in the reference image by the smoothing grayscale value in the processing target image A calculating step;
For pixels with a ratio of 1 or less, each numerical value representing a color in the processing target image is inputmg (x, y), each numerical value representing a color whose brightness is corrected is outputlmg (x, y), and the ratio A ratio (x, y), and generating the correction function represented by the following equation (1):
outputlmg (x, y) = inputlmg (x, y) * ratio (x, y) (1)
For pixels with the ratio exceeding 1, the smoothed grayscale value in the reference image is represented by referenceMap (x, y), the smoothed grayscale value in the processing target image is represented by inputMap (x, y), and the color is represented. A step of generating the correction function represented by the following formulas (2) to (4), where max is a maximum value that each numerical value can take;
outputmg (x, y) = inputmg (x, y) * rate + offset (2)
rate = (max-referenceMap (x, y)) / (max-inputMap (x, y)) (3)
offset = referenceMap (x, y) -rate * inputMap (x, y) (4)
The computer program according to claim 2, comprising:
前記参照画像は、統計情報を利用した背景モデルを用いた背景差分により特定されることを特徴とする請求項1から3までのいずれか一つに記載のコンピュータプログラム。   The computer program according to claim 1, wherein the reference image is specified by a background difference using a background model using statistical information. 演算部及び記憶部を備えるコンピュータにより、画像に写された動体を検出する動体検出方法において、
動体を検出する処理の対象となる処理対象画像を前記記憶部に記憶するステップと、
前記処理対象画像内の明るさの分布を特定の参照画像内の明るさの分布に合わせる明るさ補正を行うステップと、
明るさ補正を行った後の処理対象画像に対して、動体検出を行うステップと
を含むことを特徴とする動体検出方法。
In a moving object detection method for detecting a moving object copied in an image by a computer including a calculation unit and a storage unit,
Storing a processing target image to be a target of processing for detecting a moving object in the storage unit;
Performing brightness correction to match the brightness distribution in the processing target image with the brightness distribution in a specific reference image;
A moving object detection method comprising: performing a moving object detection on a processing target image after performing brightness correction.
画像に写された動体を検出する動体検出装置において、
動体を検出する処理の対象となる処理対象画像を記憶する記憶部と、
前記処理対象画像内の明るさの分布を特定の参照画像内の明るさの分布に合わせる明るさ補正を行う明るさ補正部と、
明るさ補正を行った後の処理対象画像に対して、動体検出を行う動体検出部と
を備えることを特徴とする動体検出装置。
In a moving object detection apparatus for detecting a moving object shown in an image,
A storage unit that stores a processing target image that is a target of processing for detecting a moving object;
A brightness correction unit that performs brightness correction to match the brightness distribution in the processing target image with the brightness distribution in a specific reference image;
A moving object detection device comprising: a moving object detection unit configured to detect a moving object with respect to a processing target image after performing brightness correction.
JP2016194392A 2016-09-30 2016-09-30 Computer program, moving body detection method, and moving body detection device Active JP6743633B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2016194392A JP6743633B2 (en) 2016-09-30 2016-09-30 Computer program, moving body detection method, and moving body detection device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2016194392A JP6743633B2 (en) 2016-09-30 2016-09-30 Computer program, moving body detection method, and moving body detection device

Publications (2)

Publication Number Publication Date
JP2018055621A true JP2018055621A (en) 2018-04-05
JP6743633B2 JP6743633B2 (en) 2020-08-19

Family

ID=61836850

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2016194392A Active JP6743633B2 (en) 2016-09-30 2016-09-30 Computer program, moving body detection method, and moving body detection device

Country Status (1)

Country Link
JP (1) JP6743633B2 (en)

Also Published As

Publication number Publication date
JP6743633B2 (en) 2020-08-19

Similar Documents

Publication Publication Date Title
JP6961797B2 (en) Methods and devices for blurring preview photos and storage media
KR101036787B1 (en) Motion vector calculation method, hand-movement correction device using the method, imaging device, and motion picture generation device
CN108668093B (en) HDR image generation method and device
US8508605B2 (en) Method and apparatus for image stabilization
JP6499188B2 (en) How to convert a saturated image to a non-saturated image
JP6074254B2 (en) Image processing apparatus and control method thereof
WO2014012364A1 (en) Method and device for correcting multi-exposure motion image
JP2012089929A (en) Object detection apparatus, object detection method, monitoring camera system and program
AU2016225841A1 (en) Predicting accuracy of object recognition in a stitched image
KR20180102639A (en) Image processing apparatus, image processing method, image processing program, and storage medium
JP2008259161A (en) Target tracing device
US11457158B2 (en) Location estimation device, location estimation method, and program recording medium
JP6178646B2 (en) Imaging apparatus and image shake correction processing method
JP4628851B2 (en) Object detection method and object detection apparatus
JP2021111929A (en) Imaging device, control method of imaging device, and program
JP2011145766A (en) Image processing apparatus, image display system, and image processing method
CN111445411A (en) Image denoising method and device, computer equipment and storage medium
JP6743633B2 (en) Computer program, moving body detection method, and moving body detection device
JP2019020839A (en) Image processing apparatus, image processing method and program
JP6378496B2 (en) Image processing apparatus, control method, and recording medium
JP2009258770A (en) Image processing method, image processor, image processing program, and imaging device
JP6541416B2 (en) IMAGE PROCESSING APPARATUS, IMAGE PROCESSING METHOD, PROGRAM, AND STORAGE MEDIUM
JP2018160024A (en) Image processing device, image processing method and program
JP2015076676A (en) Image processing apparatus, image processing method, and program
JP2013246601A (en) Image process device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20190729

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20200526

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20200610

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20200630

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20200713

R150 Certificate of patent or registration of utility model

Ref document number: 6743633

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150