CN111724426A - Background modeling method and camera for background modeling - Google Patents

Background modeling method and camera for background modeling Download PDF

Info

Publication number
CN111724426A
CN111724426A CN201910209064.5A CN201910209064A CN111724426A CN 111724426 A CN111724426 A CN 111724426A CN 201910209064 A CN201910209064 A CN 201910209064A CN 111724426 A CN111724426 A CN 111724426A
Authority
CN
China
Prior art keywords
pixel
pixel point
background
statistical
value
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
CN201910209064.5A
Other languages
Chinese (zh)
Other versions
CN111724426B (en
Inventor
张彩红
刘刚
张昱升
曾峰
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.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology 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 Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201910209064.5A priority Critical patent/CN111724426B/en
Publication of CN111724426A publication Critical patent/CN111724426A/en
Application granted granted Critical
Publication of CN111724426B publication Critical patent/CN111724426B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/40Analysis of texture
    • G06T7/41Analysis of texture based on statistical description of texture
    • G06T7/44Analysis of texture based on statistical description of texture using image operators, e.g. filters, edge density metrics or local histograms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence

Abstract

The embodiment of the invention provides a background modeling method and a camera for background modeling, wherein a frame of image is obtained from a collected video image sequence, the pixel values of all pixel points in a preset neighborhood range of each pixel point in the image and the statistical number of each pixel value are respectively counted, a background sub-model corresponding to each pixel point is established according to the pixel values respectively counted by each pixel point and the statistical number of each pixel value, and the background sub-model corresponding to each pixel point is utilized to establish the background model of the video image sequence. By the scheme, a relatively accurate background model can be established by utilizing a pixel value counting mode, complex modeling and calculating processes are not needed, and the speed and efficiency of background modeling are improved.

Description

Background modeling method and camera for background modeling
Technical Field
The invention relates to the technical field of video monitoring, in particular to a background modeling method and a camera for background modeling.
Background
The detection of dynamic objects from a video sequence is a primary and fundamental task of video surveillance. At present, many tracking systems rely on background extraction technology for detecting moving objects, that is, a currently input video frame is compared with a background model, and whether a pixel point is a target pixel or a background pixel is determined according to the deviation degree of the pixel point of the current video frame and the background model. Then, the pixel points which are considered as the target are further processed so as to identify the target, determine the position of the target and further realize the tracking. Therefore, the establishment of the background model directly affects the accuracy of target tracking, and how to establish the accurate background model is the key to realize target tracking.
At present, a popular background modeling method is a gaussian mixture modeling method, and is composed of K (generally 3-5) gaussian models in a weighted manner, if the matching degree of a pixel point in a current video frame and one of the K models of the pixel point is high, the pixel point is considered as a background, otherwise, the pixel point is considered as a foreground, the pixel point is used as a new model, and the existing K models are updated. The model established by the Gaussian mixture modeling method is an intuitive probability density model and can adapt to illumination change and multi-modal scenes.
However, K gaussian models need to be established for each pixel point, and the process of establishing the gaussian models is complex and has a large calculation amount, so that the background modeling speed is low and the efficiency is low.
Disclosure of Invention
The embodiment of the invention aims to provide a background modeling method and a camera for background modeling, so as to improve the speed and efficiency of background modeling. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a background modeling method, where the method includes:
acquiring a frame of image from an acquired video image sequence;
respectively counting the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the counting number of each pixel value, wherein the pixel values indicate the gray value and/or the color value;
establishing a background sub-model corresponding to each pixel point according to the pixel value counted respectively for each pixel point and the counted number of each pixel value, wherein the background sub-model comprises the pixel value and the counted number of the pixel value;
and building a background model of the video image sequence by using the background sub-models corresponding to the pixel points.
Optionally, the color value is a value of a designated color channel or an array composed of values of each color channel, and the gray value is an average value of the values of each color channel.
Optionally, the establishing a background sub-model corresponding to each pixel point according to the pixel value respectively counted for each pixel point and the counted number of each pixel value includes:
aiming at each pixel point, the following operations are respectively executed:
counting the number of kinds of pixel values in a preset neighborhood range of a first pixel point, wherein the first pixel point is any one of the pixel points;
judging whether the number of the types is larger than the number of preset background samples or not;
if so, reading a plurality of pixel values with the same number as the preset background sample number and the statistical number of each pixel value in the plurality of pixel values to form a background sub-model corresponding to the first pixel point;
if not, reading the pixel values of all the pixel points in the preset neighborhood range and the statistical number of each pixel value, and forming a background sub-model corresponding to the first pixel point with a plurality of zero-valued pixel values and zero-valued statistical numbers, wherein the number of the zero-valued pixel values and the zero-valued statistical numbers is equal to the difference between the preset background sample number and the type number.
Optionally, after the calculating the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the statistical number of each pixel value respectively, the method further includes:
arranging elements consisting of pixel values and the statistical number of the pixel values according to the sequence of the statistical number from large to small to obtain a pixel value set;
the reading a plurality of pixel values with the same number as the preset background sample number and the statistical number of each pixel value in the plurality of pixel values to form a background sub-model corresponding to the first pixel point, including:
and reading a plurality of elements from the pixel value set according to the preset background sample number and the arrangement sequence from front to back to form a background sub-model corresponding to the first pixel point.
Optionally, after the background sub-model corresponding to each pixel point is used to construct the background model of the video image sequence, the method further includes:
acquiring a pixel value of each pixel point in a current video frame;
updating the background sub-model corresponding to each pixel point in the current video frame based on a judgment result of whether the pixel value of each pixel point in the current video frame is respectively contained in the background sub-model corresponding to each pixel point in the current video frame according to the pixel value of each pixel point in the current video frame;
and determining the updated background model according to the updated background sub-model corresponding to each pixel point in the current video frame.
Optionally, the updating, according to the pixel value of each pixel in the current video frame, the background sub-model corresponding to each pixel in the current video frame based on the determination result of whether the pixel value of each pixel in the current video frame is respectively included in the background sub-models corresponding to each pixel in the current video frame includes:
aiming at each pixel point in the current video frame, the following operations are respectively executed:
judging whether the pixel value of a second pixel point is contained in a background sub-model corresponding to the second pixel point, wherein the second pixel point is any one pixel point in the current video frame;
if so, determining elements with the pixel values identical to the pixel values of the second pixel points in a background sub-model corresponding to the second pixel points, wherein the background sub-model comprises a plurality of elements, and each element comprises a pixel value and the statistical number of the pixel values; adding 1 to the statistical number in the elements, and subtracting 1 from the statistical number in other elements except the elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, the any statistical number is kept to be 0;
if not, subtracting 1 from the statistical number of all elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, keeping any statistical number to be 0; determining the serial number of the element with non-zero and minimum statistical number in the background sub-model corresponding to the second pixel point; judging whether the serial number is smaller than the number of preset background samples or not; if the pixel value is smaller than the first pixel point, setting the statistical number in the element of the next sequence number in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the element of the next sequence number to be the pixel value of the second pixel point; if not, setting the statistical number in the last element in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the last element to be the pixel value of the second pixel point.
Optionally, before the adding 1 to the statistical number of the elements, the method further includes:
judging whether the statistical number in the elements reaches a preset threshold value or not;
if so, keeping the statistical number in the elements unchanged as the preset threshold value;
and if not, executing the step of adding 1 to the statistical number in the elements.
Optionally, after determining the updated background model according to the updated background sub-model corresponding to each pixel point in the current video frame, the method further includes:
acquiring a pixel value of a third pixel point in the current video frame and the statistical number of the pixel values of the third pixel point, wherein the third pixel point is any one pixel point in the current video frame;
superposing the statistical numbers in the background sub-model corresponding to the third pixel point in the background model to obtain the statistical number sum corresponding to the third pixel point;
and calculating the foreground probability of the third pixel point according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number.
Optionally, the calculating the foreground probability of the third pixel according to the statistical number of the pixel values of the third pixel and the sum of the statistical numbers includes:
calculating the foreground probability of the third pixel point by using a foreground probability calculation formula according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number, wherein the foreground probability calculation formula is as follows:
Figure BDA0001999933830000041
wherein FG (x, y) is the foreground probability of the third pixel, (x, y) is the coordinate of the third pixel, snkIs the statistical number of pixel values of the third pixel point,
Figure BDA0001999933830000042
is the sum of said statistical numbers sniAnd the number is the ith statistical number in the background sub-model corresponding to the third pixel point, and N is the number of preset background samples.
In a second aspect, an embodiment of the present invention provides a background modeling apparatus, where the apparatus includes:
the acquisition module is used for acquiring a frame of image from the acquired video image sequence;
the statistical module is used for respectively counting the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the statistical number of each pixel value, and the pixel values indicate the gray value and/or the color value;
the establishing module is used for establishing a background sub-model corresponding to each pixel point according to the pixel value respectively counted aiming at each pixel point and the counting number of each pixel value, and the background sub-model comprises the pixel value and the counting number of the pixel value;
and the building module is used for building a background model of the video image sequence by using the background sub-models corresponding to the pixel points.
Optionally, the color value is a value of a designated color channel or an array composed of values of each color channel, and the gray value is an average value of the values of each color channel.
Optionally, the establishing module is specifically configured to:
aiming at each pixel point, the following operations are respectively executed:
counting the number of kinds of pixel values in a preset neighborhood range of a first pixel point, wherein the first pixel point is any one of the pixel points;
judging whether the number of the types is larger than the number of preset background samples or not;
if so, reading a plurality of pixel values with the same number as the preset background sample number and the statistical number of each pixel value in the plurality of pixel values to form a background sub-model corresponding to the first pixel point;
if not, reading the pixel values of all the pixel points in the preset neighborhood range and the statistical number of each pixel value, and forming a background sub-model corresponding to the first pixel point with a plurality of zero-valued pixel values and zero-valued statistical numbers, wherein the number of the zero-valued pixel values and the zero-valued statistical numbers is equal to the difference between the preset background sample number and the type number.
Optionally, the apparatus further comprises:
the arrangement module is used for arranging elements formed by the pixel values and the statistical numbers of the pixel values according to the sequence of the statistical numbers from large to small to obtain a pixel value set;
the establishing module, when configured to read the number of the plurality of pixel values equal to the number of the preset background samples and the statistical number of each of the plurality of pixel values to form the background sub-model corresponding to the first pixel point, is specifically configured to:
and reading a plurality of elements from the pixel value set according to the preset background sample number and the arrangement sequence from front to back to form a background sub-model corresponding to the first pixel point.
Optionally, the obtaining module is further configured to obtain a pixel value of each pixel point in the current video frame;
the device further comprises:
the updating module is used for updating the background sub-model corresponding to each pixel point in the current video frame based on a judgment result of whether the pixel value of each pixel point in the current video frame is respectively contained in the background sub-model corresponding to each pixel point in the current video frame according to the pixel value of each pixel point in the current video frame;
and the determining module is used for determining the updated background model according to the updated background sub-model corresponding to each pixel point in the current video frame.
Optionally, the update module is specifically configured to:
aiming at each pixel point in the current video frame, the following operations are respectively executed:
judging whether the pixel value of a second pixel point is contained in a background sub-model corresponding to the second pixel point, wherein the second pixel point is any one pixel point in the current video frame;
if so, determining elements with the pixel values identical to the pixel values of the second pixel points in a background sub-model corresponding to the second pixel points, wherein the background sub-model comprises a plurality of elements, and each element comprises a pixel value and the statistical number of the pixel values; adding 1 to the statistical number in the elements, and subtracting 1 from the statistical number in other elements except the elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, the any statistical number is kept to be 0;
if not, subtracting 1 from the statistical number of all elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, keeping any statistical number to be 0; determining the serial number of the element with non-zero and minimum statistical number in the background sub-model corresponding to the second pixel point; judging whether the serial number is smaller than the number of preset background samples or not; if the pixel value is smaller than the first pixel point, setting the statistical number in the element of the next sequence number in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the element of the next sequence number to be the pixel value of the second pixel point; if not, setting the statistical number in the last element in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the last element to be the pixel value of the second pixel point.
Optionally, the apparatus further comprises:
the judging module is used for judging whether the statistical number in the elements reaches a preset threshold value or not;
the keeping module is used for keeping the statistical number in the elements unchanged as the preset threshold value if the judgment result of the judging module is reached;
the updating module is specifically configured to, if the determination result of the determining module is that the statistical number in the element is not reached, add 1 to the statistical number in the element.
Optionally, the obtaining module is further configured to obtain a pixel value of a third pixel in the current video frame and a statistical number of the pixel values of the third pixel, where the third pixel is any pixel in the current video frame;
the device further comprises:
the calculation module is used for superposing the statistical numbers in the background sub-model corresponding to the third pixel point in the background model to obtain the statistical number sum corresponding to the third pixel point; and calculating the foreground probability of the third pixel point according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number.
Optionally, the calculation module is specifically configured to:
calculating the foreground probability of the third pixel point by using a foreground probability calculation formula according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number, wherein the foreground probability calculation formula is as follows:
Figure BDA0001999933830000071
wherein FG (x, y) is the foreground probability of the third pixel, (x, y) is the coordinate of the third pixel, snkIs the statistical number of pixel values of the third pixel point,
Figure BDA0001999933830000072
is the sum of said statistical numbers sniAnd the number is the ith statistical number in the background sub-model corresponding to the third pixel point, and N is the number of preset background samples.
In a third aspect, an embodiment of the present invention provides a camera for background modeling, where the camera includes a camera, a processor, and a memory;
the camera is used for acquiring a video image sequence;
the memory is used for storing a computer program;
the processor is configured to implement the method steps of the first aspect of the embodiment of the present invention when executing the computer program stored in the memory.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps of the first aspect of the embodiment of the present invention.
According to the background modeling method and the camera for background modeling provided by the embodiment of the invention, a frame of image is obtained from a collected video image sequence, the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the statistical number of each pixel value are respectively counted, a background sub-model corresponding to each pixel point is established according to the pixel values respectively counted by each pixel point and the statistical number of each pixel value, and the background sub-model corresponding to each pixel point is utilized to establish the background model of the video image sequence. The background sub-model of the pixel point is established by utilizing the pixel values and the statistical number of the pixel values of all the pixel points in the preset neighborhood range of the pixel point, and then the background model of the video image sequence is established to be used as the pixel point of the background, and the statistical number of the pixel values of the pixel point is usually larger, so that the more accurate background model can be established by utilizing the counting mode of the pixel values, the complex modeling and calculating processes are not needed, and the speed and the efficiency of background modeling are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic diagram of a background modeling method according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a neighborhood range of a background modeling method according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating background model updating of a background modeling method according to an embodiment of the present invention;
FIG. 4a is an image captured by a camera in accordance with an embodiment of the present invention;
FIG. 4b is a foreground effect image corresponding to FIG. 4 a;
FIG. 4c is another image captured by the camera according to the embodiment of the present invention;
FIG. 4d is the corresponding foreground effect image of FIG. 4 c;
FIG. 4e is a further image captured by the camera in accordance with the present invention;
FIG. 4f is the foreground effect image corresponding to FIG. 4 e;
FIG. 4g is a further image captured by a camera in accordance with an embodiment of the present invention;
FIG. 4h is the foreground effect image corresponding to FIG. 4 g;
FIG. 4i is a further image captured by a camera in accordance with an embodiment of the present invention;
FIG. 4j is the foreground effect image corresponding to FIG. 4 i;
FIG. 4k is a further image captured by a camera in accordance with an embodiment of the present invention;
FIG. 4l is the foreground effect image corresponding to FIG. 4 k;
FIG. 4m is a further image captured by a camera in accordance with an embodiment of the present invention;
FIG. 4n is a foreground effect image corresponding to FIG. 4 m;
FIG. 5 is a flowchart of background modeling and foreground output of a background modeling method according to an embodiment of the present invention;
FIG. 6 is a functional block diagram of a background modeling apparatus according to an embodiment of the present invention;
fig. 7 is a block diagram of a camera for background modeling according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to improve the speed and efficiency of background modeling, the embodiment of the invention provides a background modeling method, a background modeling device, a camera for background modeling and a computer-readable storage medium. Next, a background modeling method provided in an embodiment of the present invention is described first.
An execution subject of the background modeling method provided by the embodiment of the invention can be an electronic device with an image processing function, such as a camera. In order to improve the speed and efficiency of background modeling, the execution body should include at least a processor on which a core processing chip is mounted. The background modeling method provided by the embodiment of the invention can be realized by at least one of software, hardware circuit and logic circuit arranged in the execution main body.
As shown in fig. 1, a background modeling method provided by an embodiment of the present invention may include the following steps.
S101, acquiring a frame of image from the acquired video image sequence.
In this embodiment, a camera in a camera acquires a video image sequence V ═ f0,f1,…,ft…, a frame of image may be taken from either of them as a reference image for establishing an initial background model. Since the background model is continuously updated, the first frame image in the video image sequence is usually acquired as a reference image for establishing the initial background model.
Alternatively, the acquired image may be the first frame image in a sequence of video images.
S102, respectively counting the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the counting number of each pixel value, wherein the pixel values indicate the gray value and/or the color value.
The preset neighborhood range is a certain image range in which a certain pixel point in an image is located, and a neighborhood range comprises a plurality of pixel points around the pixel point besides the pixel point for establishing a background sub-model, and under normal conditions, the size of the neighborhood range is not suitable to be set to be too large or too small, and is usually set to be 3 x 3 or 5 x 5. The pixel value refers to a pixel value representing a pixel point, and may indicate a gray value and/or a color value, and certainly may also indicate an LBP (Local Binary Pattern) characteristic value, and the like.
Optionally, the color value may be a value of a designated color channel or an array formed by values of each color channel, and the grayscale value may be an average value of the values of each color channel.
In the RGB image, the color value may be a value of a designated channel in the R channel, the G channel, and the B channel, or may be an array formed by values of three channels of the R channel, the G channel, and the B channel, and the gray value is an average value of the values of the three channels.
After the image is obtained, each pixel point in the image can be traversed, taking the pixel point at (x, y) as an example, the pixel value in the preset neighborhood range and the statistical number of each pixel value are counted, and the pixel value set { (p) of the pixel point can be formed based on the counted pixel value and the statistical number1,n1),(p2,n2),…,(pk,nk) Where pi is the ith pixel value, niIs the statistical number of the ith pixel value. As shown in fig. 2, for a pixel at (x, y), the pixel value of each pixel in the region divided by a preset neighborhood range of 3 × 3, in the preset neighborhood range, the statistical number of the pixel value with a specific value of 20 is 1, the statistical number of the pixel value with a specific value of 25 is 3, the statistical number of the pixel value with a specific value of 30 is 3, and the statistical number of the pixel value with a specific value of 50 is 2, then a pixel value set { (20,1), (25,3), (50,2), (30,3) } may be formed.
Optionally, after executing S102, the method provided in the embodiment of the present invention may further include the following steps:
and arranging elements consisting of the pixel values and the statistical numbers of the pixel values according to the sequence of the statistical numbers from large to small to obtain a pixel value set.
Since the larger the statistical number is, the higher the possibility that the pixel is a background pixel is, in order to reflect whether the pixel is a background pixel and facilitate subsequent background updating, the statistical elements may be sorted in the order of the statistical number from large to small to obtain { (sp)1,sn1),(sp2,sn2),…,(spk,snk) For example, the set of pixel values obtained by sorting the statistical data shown in fig. 2 is { (25,3), (30,3), (50,2), (20,1) }.
S103, establishing a background sub-model corresponding to each pixel point according to the pixel values respectively counted by each pixel point and the counted number of each pixel value, wherein the background sub-model comprises the pixel values and the counted number of the pixel values.
After the pixel values of all the pixel points in the preset neighborhood range of each pixel point and the statistical number of each pixel value are obtained through statistics, the background sub-model corresponding to each pixel point can be established according to the statistical pixel values and the statistical number of each pixel value. Specifically, the statistical pixel values and the statistical number of each pixel value may be stored in the pixel value set, and then the background sub-module corresponding to each pixel point may be established according to each element in the pixel value set. The background sub-model is actually composed of statistical pixel values and a statistical number of the pixel values, and may be selected from a set of pixel values. Specifically, the number of elements in the background sub-model may be the same as the number of preset background samples, and the background sub-model corresponding to the jth pixel point is actually:
BGj={(val1,count1),(val2,count2),…,(valN,countN)} (1)
where val is the pixel value, count is the statistical number, and N is the number of the predetermined background samples.
Optionally, S103 may specifically include:
aiming at each pixel point, the following operations are respectively executed:
counting the type number of pixel values in a preset neighborhood range of a first pixel point, wherein the first pixel point is any one of the pixel points; judging whether the number of the types is larger than the number of preset background samples or not; if so, reading a plurality of pixel values with the same number as the number of the preset background samples and the statistical number of each pixel value to form a background sub-model corresponding to the first pixel point; and if not, reading the pixel values of all the pixels in the preset neighborhood range and the statistical number of each pixel value, and forming a background sub-model corresponding to the first pixel point with a plurality of zero-valued pixel values and zero-valued statistical numbers, wherein the quantity of the zero-valued pixel values and the zero-valued statistical numbers is equal to the difference between the preset background sample number and the type number.
When the background sub-model is established, whether the number of the types of the pixel values in the statistical preset neighborhood range is larger than the number of the preset background samples or not can be judged. If the number of the elements is not larger than the preset number, all the statistical information can be used as the elements in the background submodel, and the rest elements can be set to be 0, so that the total number of the elements in the background submodel is equal to the preset number of the background samples; if it is larger, the group needs to sort out a part of the statistical information as the element in the background sub-model, and in general, a statistical number of pixel values and a statistical number are read as the element in the background sub-model. Since the counted pixel values and the counted number may be stored in the pixel value set according to an order from a large statistical number to a small statistical number, optionally, the step of reading a plurality of pixel values with the same number as the preset background sample number and the statistical number of each pixel value to form the background sub-model corresponding to the first pixel point may specifically be:
and reading a plurality of elements from the pixel value set according to the preset background sample number and the arrangement sequence from front to back to form a background sub-model corresponding to the first pixel point.
Assuming that the number of the preset background samples is N, the background submodel corresponding to the first pixel point can be formed by the first N elements selected from the pixel value set. To ensure that a statistically large number of elements can be picked from the sequence of pixel values as elements in the background sub-model.
And S104, building a background model of the video image sequence by using the background sub-models corresponding to the pixel points.
After a background sub-model is established for each pixel point in the image, a background model of the video image sequence can be established based on the background sub-model corresponding to each pixel point, and the background model can be a set of the background sub-models corresponding to each pixel point.
By applying the embodiment, a frame of image is obtained from a collected video image sequence, the pixel values of all the pixels in the preset neighborhood range of each pixel in the image and the statistical number of each pixel value are respectively counted, a background sub-model corresponding to each pixel is established according to the pixel values counted respectively for each pixel and the statistical number of each pixel value, and the background sub-model corresponding to each pixel is utilized to establish the background model of the video image sequence. The background sub-model of the pixel point is established by utilizing the pixel values and the statistical number of the pixel values of all the pixel points in the preset neighborhood range of the pixel point, and then the background model of the video image sequence is established to be used as the pixel point of the background, and the statistical number of the pixel values of the pixel point is usually larger, so that the more accurate background model can be established by utilizing the counting mode of the pixel values, the complex modeling and calculating processes are not needed, and the speed and the efficiency of background modeling are improved. And, presetting the number of background samples as 2 can realize background modeling, so the storage space of the model can be reduced to the greatest extent under the condition of better effect.
The background model constructed in the embodiment shown in fig. 1 is actually an initialized background model, and during video monitoring, the background model needs to be updated continuously, and some infrequently changing pixel points are updated as background pixels to improve the accuracy of the background model, so that after the background model of a video image sequence is constructed, the background model updating process shown in fig. 3 needs to be executed.
S301, acquiring the pixel value of each pixel point in the current video frame.
Assume that the current video frame is ftThe updating is performed by comparing the pixel values in the current frame with the pixel values in the background model. Therefore, the pixel value of each pixel point in the current video frame is obtained first.
S302, updating the background sub-model corresponding to each pixel point in the current video frame based on the judgment result of whether the pixel value of each pixel point in the current video frame is respectively contained in the background sub-model corresponding to each pixel point in the current video frame according to the pixel value of each pixel point in the current video frame.
After the pixel value of each pixel point in the current video frame is obtained, the background sub-model of each pixel point can be updated by comparing the pixel value of each pixel point in the current video frame with the corresponding background sub-model in the background model. Specifically, the comparison is performed by determining whether the pixel value is included in the background sub-model.
Optionally, in S302, specifically, the following operations are respectively performed for each pixel point in the current video frame:
s3021, determining whether the pixel value of the second pixel is included in the background sub-model corresponding to the second pixel, where the second pixel is any pixel in the current video frame, if so, performing S3022 to S3023, and otherwise, performing S3024 to S3026.
Assume that the pixel value of the second pixel point is ftq(x, y), the background sub-model corresponding to the second pixel point is BGq(x, y), the way of determining whether the pixel value is included in the corresponding background sub-model may be ftq(x, y) and BGqAnd (x, y) intersecting, and judging whether the intersecting result is null or not. If the background submodel BG is empty, the background submodel BG is indicatedq(x, y) does not include the pixel value ftq(x, y); if not, indicating the background sub-model BGq(x, y) includes a pixel value ftq(x,y)。
And S3022, determining elements with the same pixel values as the pixel values of the second pixel points in the background sub-model corresponding to the second pixel point, wherein the background sub-model comprises a plurality of elements, and each element comprises a pixel value and the statistical number of the pixel values.
And S3023, adding 1 to the statistical number in the element having the same pixel value as the pixel value of the second pixel point, and subtracting 1 from the statistical number in the other elements except the element in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, the statistical number is kept to be 0.
If the pixel value ftq(x, y) is included in the background submodel BGq(x, y) first, the background submodel BG needs to be determinedq(x, y) pixel value and pixel value ftq(x, y) the same elements. Pixel value ftq(x, y) appearing in the background model, which indicates the possibility that the pixel point is a background pixel, and may be a pixel point which is not changed for several continuous frames in the monitoring scene, the confidence that the pixel point is the background pixel can be increased, so that the statistical number of the pixel values in the corresponding background sub-model can be correspondingly increased; for other pixel values in the background sub-model, these pixels may be reducedThe statistical number of values, reduces the confidence that these pixel values are background. Suppose ftq(x,y)=piI.e. the pixel value ftq(x, y) and background submodel BGqIf the pixel value of the ith element in (x, y) is the same, n is addediAdding 1, namely adding 1 to the statistical number in the ith element, subtracting 1 from other n, and ensuring that n is more than or equal to 0, namely the background sub-model updated based on the second pixel point is as follows:
{(p1,n1-1),…,(pi,ni-1),…,(pN,nN-1)} (2)
s3024, subtracting 1 from the statistical number of all elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, the statistical number is kept to be 0.
If background submodel BGq(x, y) does not include the pixel value ftq(x, y), if the pixel point is not the background pixel, the background sub-model BG can be reducedqAnd (x, y) counting the number of all pixel values, and reducing the confidence coefficient of the pixel point as a background pixel.
And S3025, determining the serial number of the element with the non-zero statistical number and the minimum statistical number in the background sub-model corresponding to the second pixel point.
And S3026, judging whether the serial number is less than the number of the preset background samples, if so, executing S3027, otherwise, executing S3028.
S3027, setting the statistical number in the element of the next sequence number in the background sub-model corresponding to the second pixel point to 1, and setting the pixel value in the element of the next sequence number to the pixel value of the second pixel point.
And S3028, setting the statistical number of the last element in the background sub-model corresponding to the second pixel point to 1, and setting the pixel value of the last element to be the pixel value of the second pixel point.
To cope with the situation where a new object appears in the monitored scene, which object may not move in the subsequent monitored scene, a corresponding sample of pixels may be added in the background sub-model, assuming a minimum non-zero niIs the ith pixel sample, if i<N, then set Ni+11 and pi+1=ftq(x, y), if i is not less than N, setting NN1 and pNFt (x, y). Since the elements in the background sub-model are generally arranged in the order of the statistical number from large to small, when adding the corresponding pixel sample and the statistical number, the latter element of the element with the smallest statistical number and non-zero statistical number can be set.
Optionally, before executing S3023, the method provided in the embodiment of the present invention may further execute the following steps:
judging whether the statistical number in the elements reaches a preset threshold value or not; if so, keeping the statistical number in the elements unchanged at a preset threshold value; if not, the step of adding 1 to the statistical number of the elements in S3023 is executed.
If a pixel point is not changed in the video sequence, according to the method provided in this embodiment, the statistical number of the pixel value corresponding to the pixel point is increased all the time, and if the statistical number becomes large, not only a large storage space is required, which causes an anomaly of the background model, but also a Ghost (Ghost or smear) phenomenon of the foreground is severe. To avoid the Ghost phenomenon, a threshold value, for example 255, may be set, before adding 1 to the statistical number, first determine whether the statistical number in the element reaches the threshold value of 255, if not, add 1 to the statistical number, and if so, keep the threshold value of 255 as the statistical number unchanged. By detecting the image shown in fig. 4a, the foreground effect image shown in fig. 4b can be obtained, where the dark area is the foreground and the Ghost area in fig. 4b is not obvious.
And S303, determining an updated background model according to the updated background sub-model corresponding to each pixel point in the current video frame.
And updating the background sub-model corresponding to each pixel point based on each pixel point in the current frame, so that the aim of updating the background model can be fulfilled, and for each video frame in the video image sequence, the background model is updated based on the pixel points in the video frame.
Optionally, after step S303 is executed, the method provided in the embodiment of the present invention may further execute the following steps:
s3031, obtaining the pixel value of a third pixel point in the current video frame and the statistical number of the pixel values of the third pixel point, wherein the third pixel point is any pixel point in the current video frame.
S3032, the statistical numbers in the background sub-model corresponding to the third pixel point in the background model are superposed to obtain the statistical number sum corresponding to the third pixel point.
S3033, calculating the foreground probability of the third pixel point according to the statistical number and the statistical number sum of the pixel values of the third pixel point.
When the updated background model is used for target identification, a third pixel point (any pixel point) in the current video frame can be analyzed to obtain a corresponding pixel value and a statistical number, the statistical number can be obtained from a corresponding background sub-model, the statistical number is compared with the total statistical number, the probability that the pixel point is the background can be obtained, and correspondingly, the probability that the pixel point is the foreground can be converted.
Optionally, S3033 may specifically be:
calculating the foreground probability of the third pixel point by utilizing a foreground probability calculation formula according to the statistical number and the statistical number sum of the pixel values of the third pixel point, wherein the foreground probability calculation formula is as follows:
Figure BDA0001999933830000161
FG (x, y) is the foreground probability of the third pixel, and (x, y) is the coordinate of the third pixel, snkIs the statistical number of pixel values of the third pixel point,
Figure BDA0001999933830000162
as a sum of statistical numbers sniAnd the number is the ith statistical number in the background sub-model corresponding to the third pixel point, and N is the preset background sample number.
By applying the embodiment, the background model is updated based on each video frame in the video image sequence, so that the background model is more accurate, in the process of updating the model, only the operation of adding 1 or subtracting 1 is needed to be carried out on the statistical number, the calculation is simple, the foreground residue can be objectively reduced to a greater extent, the updating of the background model can be rapidly realized, and in addition, the threshold value of the statistical number is limited, so that the Ghost phenomenon caused by too large number is avoided.
For the convenience of understanding, the background modeling method provided by the embodiment of the present invention is described below by using a complete example and a specific recognition result. As shown in fig. 5, a flow chart of the background modeling process for this example is shown.
The processing of the video image sequence is divided into two parts, the first part is a background modeling process, and the second part is foreground output. In the background modeling process, the method mainly comprises the following steps:
first, initialization.
Assume that the video image size is W × H and the video sequence is V ═ f0,f1,…,ft…, and the number of background samples is N, the background model is:
BG={(val1,count1),(val2,count2),…,(valN,countN)} (4)
where val is the pixel value and count is the statistical number.
The initialization procedure is to set all val and count in the background model to zero.
And secondly, counting the neighborhood value.
Setting the size of a neighborhood window to Win, and traversing the first frame image f0Each pixel of (x, y), taking the pixel at (x, y) as an example, counts the pixel values in the preset neighborhood range and the statistical number of each pixel value, and the number can be counted by using a counter to obtain:
{(p1,n1),(p2,n2),…,(pk,nk)} (5)
the counts are sorted (in order of the statistical number from large to small) to yield:
{(sp1,sn1),(sp2,sn2),…,(spk,snk)} (6)
and thirdly, a background model BG.
Judging the sizes of k and N, if k is less than or equal to N, filling the corresponding pixel value and the statistical number in the formula (6) into the corresponding position of (x, y) in the formula (1) (the background submodel of the embodiment shown in the figure 1); if k > N, the first N pixel values and the statistical number in equation (6) are filled in to the (x, y) correspondence in equation (1).
Traversing the whole image, a background model BG can be established.
Step four, the pixel value f of the current framet(x, y) is compared to the background model.
Suppose the current frame is ftThe updating is performed by comparing the pixel values in the current frame with the pixel values in the background model.
The fifth step, judge ftAnd (x, y) whether the (x, y) belongs to BG (x, y), if so, executing the sixth step, otherwise, executing the seventh step.
Sixth, BG (x, y) pixel value counts.
If it is
Figure BDA0001999933830000181
I.e. ft(x, y) belongs to BG (x, y), then all counts in BG (x, y) are decremented by 1, i.e.:
{(val1,count1-1),(val2,count2-1),…,(valN,countN-1)}
={(sp1,sn1-1),(sp2,sn2-1),…,(spN,snN-1)} (7)
wherein sn is guaranteed to be greater than or equal to 0, assuming a minimum non-zero sniFor the ith pixel sample:
if i<N, then set sni+11 and spi+1=ft(x,y);
If i is more than or equal to N, sn is setN1 and spN=ft(x,y)。
Seventhly, the new pixel value counts a replacement BG minimum non-0 counter.
If it is
Figure BDA0001999933830000182
I.e. ft(x, y) does not belong to BG (x, y), assuming ft(x,y)=valiThen sn will beiAdding 1, subtracting 1 from other sn, and ensuring that sn is more than or equal to 0, namely:
{(val1,count1-1),…,(vali,counti+1),…,(valN,countN-1)}
={(sp1,sn1-1),…,(spi,sni+1),…,(spN,snN-1)} (8)
eighth, counter sorting
Sorting the formula (7) or the formula (8) by using the count value sn, so that the background model of the current pixel point is as follows:
{(sp1,sn1),(sp2,sn2),…,(spN,snN)} (9)
wherein sn1>sn2>…>snN
Based on the above steps, the updated background model can be obtained.
The foreground output process mainly comprises the following steps: distinguishing the foreground and the background of the current frame by using a formula (9) to obtain the current frame ftComparing with background model BG, setting current frame ftThe counter value corresponding to (x, y) is snkThen, the foreground probability of the current pixel is:
Figure BDA0001999933830000183
wherein FG (x, y) is ftForeground probability of (x, y), snkIs the value of the counter and is,
Figure BDA0001999933830000184
is the sum of the statistical numbers.
Establishing a background model by using the image gray scale as a pixel value, and calculating the foreground effect corresponding to fig. 4a obtained by using a formula (10) on a video image sequence (fig. 4a, 4c, 4e, 4g, 4i, 4k, 4m) as shown in fig. 4b, 4c as shown in fig. 4d, 4e as shown in fig. 4f, 4g as shown in fig. 4h, 4i as shown in fig. 4j, 4k as shown in fig. 4l, and 4m as shown in fig. 4 n.
Corresponding to the above method embodiment, an embodiment of the present invention provides a background modeling apparatus, as shown in fig. 6, where the background modeling apparatus may include:
an obtaining module 610, configured to obtain a frame of image from a captured video image sequence;
a counting module 620, configured to count pixel values of all pixel points in a preset neighborhood range of each pixel point in the image and a counted number of each pixel value, respectively, where the pixel values indicate gray values and/or color values;
an establishing module 630, configured to establish a background sub-model corresponding to each pixel point according to the pixel value counted respectively for each pixel point and the counted number of each pixel value, where the background sub-model includes the pixel value and the counted number of the pixel value;
and the building module 640 is configured to build a background model of the video image sequence by using the background sub-models corresponding to the pixel points.
Optionally, the color value is a value of a designated color channel or an array composed of values of each color channel, and the gray value is an average value of the values of each color channel.
Optionally, the establishing module 630 may be specifically configured to:
aiming at each pixel point, the following operations are respectively executed:
counting the number of kinds of pixel values in a preset neighborhood range of a first pixel point, wherein the first pixel point is any one of the pixel points;
judging whether the number of the types is larger than the number of preset background samples or not;
if so, reading a plurality of pixel values with the same number as the preset background sample number and the statistical number of each pixel value in the plurality of pixel values to form a background sub-model corresponding to the first pixel point;
if not, reading the pixel values of all the pixel points in the preset neighborhood range and the statistical number of each pixel value, and forming a background sub-model corresponding to the first pixel point with a plurality of zero-valued pixel values and zero-valued statistical numbers, wherein the number of the zero-valued pixel values and the zero-valued statistical numbers is equal to the difference between the preset background sample number and the type number.
Optionally, the apparatus may further include:
the arrangement module is used for arranging elements formed by the pixel values and the statistical numbers of the pixel values according to the sequence of the statistical numbers from large to small to obtain a pixel value set;
the establishing module 630, when configured to read the number of the plurality of pixel values equal to the number of the preset background samples and the statistical number of each of the plurality of pixel values to form the background sub-model corresponding to the first pixel point, may be specifically configured to:
and reading a plurality of elements from the pixel value set according to the preset background sample number and the arrangement sequence from front to back to form a background sub-model corresponding to the first pixel point.
Optionally, the obtaining module 610 may be further configured to obtain a pixel value of each pixel point in the current video frame;
the apparatus may further include:
the updating module is used for updating the background sub-model corresponding to each pixel point in the current video frame based on a judgment result of whether the pixel value of each pixel point in the current video frame is respectively contained in the background sub-model corresponding to each pixel point in the current video frame according to the pixel value of each pixel point in the current video frame;
and the determining module is used for determining the updated background model according to the updated background sub-model corresponding to each pixel point in the current video frame.
Optionally, the update module may be specifically configured to:
aiming at each pixel point in the current video frame, the following operations are respectively executed:
judging whether the pixel value of a second pixel point is contained in a background sub-model corresponding to the second pixel point, wherein the second pixel point is any one pixel point in the current video frame;
if so, determining elements with the pixel values identical to the pixel values of the second pixel points in a background sub-model corresponding to the second pixel points, wherein the background sub-model comprises a plurality of elements, and each element comprises a pixel value and the statistical number of the pixel values; adding 1 to the statistical number in the elements, and subtracting 1 from the statistical number in other elements except the elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, the any statistical number is kept to be 0;
if not, subtracting 1 from the statistical number of all elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, keeping any statistical number to be 0; determining the serial number of the element with non-zero and minimum statistical number in the background sub-model corresponding to the second pixel point; judging whether the serial number is smaller than the number of preset background samples or not; if the pixel value is smaller than the first pixel point, setting the statistical number in the element of the next sequence number in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the element of the next sequence number to be the pixel value of the second pixel point; if not, setting the statistical number in the last element in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the last element to be the pixel value of the second pixel point.
Optionally, the apparatus may further include:
the judging module is used for judging whether the statistical number in the elements reaches a preset threshold value or not;
the keeping module is used for keeping the statistical number in the elements unchanged as the preset threshold value if the judgment result of the judging module is reached;
the updating module may be specifically configured to, if the determination result of the determining module is that the statistical number in the element is not reached, add 1 to the statistical number in the element.
Optionally, the obtaining module 610 may be further configured to obtain a pixel value of a third pixel point in the current video frame and a statistical number of the pixel values of the third pixel point, where the third pixel point is any pixel in the current video frame;
the apparatus may further include:
the calculation module is used for superposing the statistical numbers in the background sub-model corresponding to the third pixel point in the background model to obtain the statistical number sum corresponding to the third pixel point; and calculating the foreground probability of the third pixel point according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number.
Optionally, the calculation module may be specifically configured to:
calculating the foreground probability of the third pixel point by using a foreground probability calculation formula according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number, wherein the foreground probability calculation formula is as follows:
Figure BDA0001999933830000221
wherein FG (x, y) is the foreground probability of the third pixel, (x, y) is the coordinate of the third pixel, snkIs the statistical number of pixel values of the third pixel point,
Figure BDA0001999933830000222
is the sum of said statistical numbers sniAnd the number is the ith statistical number in the background sub-model corresponding to the third pixel point, and N is the number of preset background samples.
By applying the embodiment, a frame of image is obtained from a collected video image sequence, the pixel values of all the pixels in the preset neighborhood range of each pixel in the image and the statistical number of each pixel value are respectively counted, a background sub-model corresponding to each pixel is established according to the pixel values counted respectively for each pixel and the statistical number of each pixel value, and the background sub-model corresponding to each pixel is utilized to establish the background model of the video image sequence. The background sub-model of the pixel point is established by utilizing the pixel values and the statistical number of the pixel values of all the pixel points in the preset neighborhood range of the pixel point, and then the background model of the video image sequence is established to be used as the pixel point of the background, and the statistical number of the pixel values of the pixel point is usually larger, so that the more accurate background model can be established by utilizing the counting mode of the pixel values, the complex modeling and calculating processes are not needed, and the speed and the efficiency of background modeling are improved.
The embodiment of the present invention further provides a camera for background modeling, as shown in fig. 7, including a camera 701, a processor 702, and a memory 703;
the camera 701 is used for acquiring a video image sequence;
the memory 703 is used for storing a computer program;
the processor 702 is configured to implement all the steps of the background modeling method provided by the embodiment of the present invention when executing the computer program stored in the memory 703.
The camera 701, the processor 702 and the memory 703 may be in data transmission via a wired connection or a wireless connection, and the camera may communicate with other devices via a wired communication interface or a wireless communication interface. Fig. 7 shows an example of data transmission via a bus, and the connection method is not limited to a specific connection method.
The Memory may include a RAM (Random Access Memory) or an NVM (Non-Volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
In this embodiment, the processor can realize that: acquiring a frame of image from an acquired video image sequence, respectively counting the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the statistical number of each pixel value, establishing a background sub-model corresponding to each pixel point according to the pixel values respectively counted by each pixel point and the statistical number of each pixel value, and establishing a background model of the video image sequence by using the background sub-model corresponding to each pixel point. The background sub-model of the pixel point is established by utilizing the pixel values and the statistical number of the pixel values of all the pixel points in the preset neighborhood range of the pixel point, and then the background model of the video image sequence is established to be used as the pixel point of the background, and the statistical number of the pixel values of the pixel point is usually larger, so that the more accurate background model can be established by utilizing the counting mode of the pixel values, the complex modeling and calculating processes are not needed, and the speed and the efficiency of background modeling are improved.
In addition, the embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, all the steps of the background modeling method provided by the embodiment of the present invention are implemented.
In this embodiment, the computer-readable storage medium stores a computer program that executes the background modeling method provided by the embodiment of the present invention when executed, and thus can implement: acquiring a frame of image from an acquired video image sequence, respectively counting the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the statistical number of each pixel value, establishing a background sub-model corresponding to each pixel point according to the pixel values respectively counted by each pixel point and the statistical number of each pixel value, and establishing a background model of the video image sequence by using the background sub-model corresponding to each pixel point. The background sub-model of the pixel point is established by utilizing the pixel values and the statistical number of the pixel values of all the pixel points in the preset neighborhood range of the pixel point, and then the background model of the video image sequence is established to be used as the pixel point of the background, and the statistical number of the pixel values of the pixel point is usually larger, so that the more accurate background model can be established by utilizing the counting mode of the pixel values, the complex modeling and calculating processes are not needed, and the speed and the efficiency of background modeling are improved.
For the camera and computer-readable storage medium embodiments for background modeling, the description is simple because the contents of the method involved are substantially similar to the method embodiments described above, and the relevant points can be referred to the partial description of the method embodiments.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the camera for background modeling, and the computer-readable storage medium embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and in relation to the description, reference may be made to some of the description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A background modeling method, the method comprising:
acquiring a frame of image from an acquired video image sequence;
respectively counting the pixel values of all the pixel points in the preset neighborhood range of each pixel point in the image and the counting number of each pixel value, wherein the pixel values indicate the gray value and/or the color value;
establishing a background sub-model corresponding to each pixel point according to the pixel value counted respectively for each pixel point and the counted number of each pixel value, wherein the background sub-model comprises the pixel value and the counted number of the pixel value;
and building a background model of the video image sequence by using the background sub-models corresponding to the pixel points.
2. The method of claim 1, wherein the color value is a value of a specific color channel or an array of values of each color channel, and the gray value is an average value of the values of each color channel.
3. The method according to claim 1, wherein the establishing the background sub-model corresponding to each pixel point according to the pixel values respectively counted for each pixel point and the counted number of each pixel value comprises:
aiming at each pixel point, the following operations are respectively executed:
counting the number of kinds of pixel values in a preset neighborhood range of a first pixel point, wherein the first pixel point is any one of the pixel points;
judging whether the number of the types is larger than the number of preset background samples or not;
if so, reading a plurality of pixel values with the same number as the preset background sample number and the statistical number of each pixel value in the plurality of pixel values to form a background sub-model corresponding to the first pixel point;
if not, reading the pixel values of all the pixel points in the preset neighborhood range and the statistical number of each pixel value, and forming a background sub-model corresponding to the first pixel point with a plurality of zero-valued pixel values and zero-valued statistical numbers, wherein the number of the zero-valued pixel values and the zero-valued statistical numbers is equal to the difference between the preset background sample number and the type number.
4. The method of claim 3, wherein after the separately counting the pixel values of all the pixels in the predetermined neighborhood range of the pixels in the image and the counted number of each pixel value, the method further comprises:
arranging elements consisting of pixel values and the statistical number of the pixel values according to the sequence of the statistical number from large to small to obtain a pixel value set;
the reading a plurality of pixel values with the same number as the preset background sample number and the statistical number of each pixel value in the plurality of pixel values to form a background sub-model corresponding to the first pixel point, including:
and reading a plurality of elements from the pixel value set according to the preset background sample number and the arrangement sequence from front to back to form a background sub-model corresponding to the first pixel point.
5. The method of claim 1, wherein after the building a background model of the sequence of video images using the background sub-model corresponding to each pixel point, the method further comprises:
acquiring a pixel value of each pixel point in a current video frame;
updating the background sub-model corresponding to each pixel point in the current video frame based on a judgment result of whether the pixel value of each pixel point in the current video frame is respectively contained in the background sub-model corresponding to each pixel point in the current video frame according to the pixel value of each pixel point in the current video frame;
and determining the updated background model according to the updated background sub-model corresponding to each pixel point in the current video frame.
6. The method according to claim 5, wherein the updating the background sub-model corresponding to each pixel point in the current video frame based on the determination result of whether the pixel value of each pixel point in the current video frame is respectively included in the background sub-models corresponding to each pixel point in the current video frame according to the pixel value of each pixel point in the current video frame comprises:
aiming at each pixel point in the current video frame, the following operations are respectively executed:
judging whether the pixel value of a second pixel point is contained in a background sub-model corresponding to the second pixel point, wherein the second pixel point is any one pixel point in the current video frame;
if so, determining elements with the pixel values identical to the pixel values of the second pixel points in a background sub-model corresponding to the second pixel points, wherein the background sub-model comprises a plurality of elements, and each element comprises a pixel value and the statistical number of the pixel values; adding 1 to the statistical number in the elements, and subtracting 1 from the statistical number in other elements except the elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, the any statistical number is kept to be 0;
if not, subtracting 1 from the statistical number of all elements in the background sub-model corresponding to the second pixel point, wherein if any statistical number is 0, keeping any statistical number to be 0; determining the serial number of the element with non-zero and minimum statistical number in the background sub-model corresponding to the second pixel point; judging whether the serial number is smaller than the number of preset background samples or not; if the pixel value is smaller than the first pixel point, setting the statistical number in the element of the next sequence number in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the element of the next sequence number to be the pixel value of the second pixel point; if not, setting the statistical number in the last element in the background sub-model corresponding to the second pixel point to be 1, and setting the pixel value in the last element to be the pixel value of the second pixel point.
7. The method of claim 6, wherein prior to said adding 1 to the statistical number of said elements, the method further comprises:
judging whether the statistical number in the elements reaches a preset threshold value or not;
if so, keeping the statistical number in the elements unchanged as the preset threshold value;
and if not, executing the step of adding 1 to the statistical number in the elements.
8. The method of claim 5, wherein after determining the updated background model according to the updated background sub-model corresponding to each pixel point in the current video frame, the method further comprises:
acquiring a pixel value of a third pixel point in the current video frame and the statistical number of the pixel values of the third pixel point, wherein the third pixel point is any one pixel point in the current video frame;
superposing the statistical numbers in the background sub-model corresponding to the third pixel point in the background model to obtain the statistical number sum corresponding to the third pixel point;
and calculating the foreground probability of the third pixel point according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number.
9. The method of claim 8, wherein calculating the foreground probability of the third pixel according to the statistical number of the pixel values of the third pixel and the sum of the statistical numbers comprises:
calculating the foreground probability of the third pixel point by using a foreground probability calculation formula according to the statistical number of the pixel values of the third pixel point and the sum of the statistical number, wherein the foreground probability calculation formula is as follows:
Figure FDA0001999933820000041
wherein FG (x, y) is the foreground probability of the third pixel, (x, y) is the coordinate of the third pixel, snkIs the statistical number of pixel values of the third pixel point,
Figure FDA0001999933820000042
is the sum of said statistical numbers sniAnd the number is the ith statistical number in the background sub-model corresponding to the third pixel point, and N is the number of preset background samples.
10. A camera for background modeling, the camera comprising a camera, a processor, and a memory;
the camera is used for acquiring a video image sequence;
the memory is used for storing a computer program;
the processor, when executing the computer program stored on the memory, implementing the method of any of claims 1-9.
CN201910209064.5A 2019-03-19 2019-03-19 Background modeling method and camera for background modeling Active CN111724426B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910209064.5A CN111724426B (en) 2019-03-19 2019-03-19 Background modeling method and camera for background modeling

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910209064.5A CN111724426B (en) 2019-03-19 2019-03-19 Background modeling method and camera for background modeling

Publications (2)

Publication Number Publication Date
CN111724426A true CN111724426A (en) 2020-09-29
CN111724426B CN111724426B (en) 2023-08-04

Family

ID=72562433

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910209064.5A Active CN111724426B (en) 2019-03-19 2019-03-19 Background modeling method and camera for background modeling

Country Status (1)

Country Link
CN (1) CN111724426B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113807328A (en) * 2021-11-18 2021-12-17 济南和普威视光电技术有限公司 Target detection method, device and medium based on algorithm fusion

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060285764A1 (en) * 2005-06-20 2006-12-21 Xerox Corporation Model-based line width control
CN101489121A (en) * 2009-01-22 2009-07-22 北京中星微电子有限公司 Background model initializing and updating method based on video monitoring
CN103108159A (en) * 2013-01-17 2013-05-15 新疆电力公司乌鲁木齐电业局 Electric power intelligent video analyzing and monitoring system and method
EP2706503A2 (en) * 2012-09-11 2014-03-12 Thomson Licensing Method and apparatus for bilayer image segmentation
CN104166983A (en) * 2014-06-30 2014-11-26 中国传媒大学 Motion object real time extraction method of Vibe improvement algorithm based on combination of graph cut
CN105631862A (en) * 2015-12-21 2016-06-01 浙江大学 Background modeling method based on neighborhood characteristic and grayscale information
CN105868734A (en) * 2016-04-22 2016-08-17 江苏电力信息技术有限公司 Power transmission line large-scale construction vehicle recognition method based on BOW image representation model
CN106023259A (en) * 2016-05-26 2016-10-12 史方 Method and device for detecting moving target frequency
CN108629254A (en) * 2017-03-24 2018-10-09 杭州海康威视数字技术股份有限公司 A kind of detection method and device of moving target
CN109308711A (en) * 2017-07-26 2019-02-05 富士通株式会社 Object detection method, device and image processing equipment

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060285764A1 (en) * 2005-06-20 2006-12-21 Xerox Corporation Model-based line width control
CN101489121A (en) * 2009-01-22 2009-07-22 北京中星微电子有限公司 Background model initializing and updating method based on video monitoring
EP2706503A2 (en) * 2012-09-11 2014-03-12 Thomson Licensing Method and apparatus for bilayer image segmentation
CN103108159A (en) * 2013-01-17 2013-05-15 新疆电力公司乌鲁木齐电业局 Electric power intelligent video analyzing and monitoring system and method
CN104166983A (en) * 2014-06-30 2014-11-26 中国传媒大学 Motion object real time extraction method of Vibe improvement algorithm based on combination of graph cut
CN105631862A (en) * 2015-12-21 2016-06-01 浙江大学 Background modeling method based on neighborhood characteristic and grayscale information
CN105868734A (en) * 2016-04-22 2016-08-17 江苏电力信息技术有限公司 Power transmission line large-scale construction vehicle recognition method based on BOW image representation model
CN106023259A (en) * 2016-05-26 2016-10-12 史方 Method and device for detecting moving target frequency
CN108629254A (en) * 2017-03-24 2018-10-09 杭州海康威视数字技术股份有限公司 A kind of detection method and device of moving target
CN109308711A (en) * 2017-07-26 2019-02-05 富士通株式会社 Object detection method, device and image processing equipment

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
LUPING WANG ET AL: "An algorithm for moving target detection in IR image based on grayscale distribution and kernel function", 《JOURNAL OF CENTRAL SOUTH UNIVERSITY》 *
XU YIMING ET AL: "An optimized Vibe target detection algorithm based on gray distribution and Minkowski distance", 《2017 32ND YOUTH ACADEMIC ANNUAL CONFERENCE OF CHINESE ASSOCIATION OF AUTOMATION (YAC)》 *
刘忠等: "基于灰度分布模型的声呐图像目标检测算法", 《系统工程与电子技术》 *
孙剑芬: "基于直方图灰度归类的快速背景建模方法", 《实验室研究与探索》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113807328A (en) * 2021-11-18 2021-12-17 济南和普威视光电技术有限公司 Target detection method, device and medium based on algorithm fusion
CN113807328B (en) * 2021-11-18 2022-03-18 济南和普威视光电技术有限公司 Target detection method, device and medium based on algorithm fusion

Also Published As

Publication number Publication date
CN111724426B (en) 2023-08-04

Similar Documents

Publication Publication Date Title
CN107784654B (en) Image segmentation method and device and full convolution network system
CN110941594B (en) Splitting method and device of video file, electronic equipment and storage medium
CN109389135B (en) Image screening method and device
CN112837303A (en) Defect detection method, device, equipment and medium for mold monitoring
CN112367474B (en) Self-adaptive light field imaging method, device and equipment
CN111368636B (en) Object classification method, device, computer equipment and storage medium
CN110473238B (en) Image registration method and device, electronic equipment and storage medium
CN110969066A (en) Live video identification method and device and electronic equipment
CN110969170B (en) Image theme color extraction method and device and electronic equipment
KR20200145827A (en) Facial feature extraction model learning method, facial feature extraction method, apparatus, device, and storage medium
CN107272899B (en) VR (virtual reality) interaction method and device based on dynamic gestures and electronic equipment
CN109005367B (en) High dynamic range image generation method, mobile terminal and storage medium
CN105869175A (en) Image segmentation method and system
WO2019210707A1 (en) Image sharpness evaluation method, device and electronic device
CN114169381A (en) Image annotation method and device, terminal equipment and storage medium
CN115424264A (en) Panorama segmentation method, related device, electronic equipment and storage medium
CN111160107A (en) Dynamic region detection method based on feature matching
CN114581419A (en) Transformer insulating sleeve defect detection method, related equipment and readable storage medium
CN111724426A (en) Background modeling method and camera for background modeling
WO2015031350A1 (en) Systems and methods for memory utilization for object detection
CN113628259A (en) Image registration processing method and device
CN112784494A (en) Training method of false positive recognition model, target recognition method and device
CN113989626B (en) Multi-class garbage scene distinguishing method based on target detection model
CN114550062A (en) Method and device for determining moving object in image, electronic equipment and storage medium
CN114549884A (en) Abnormal image detection method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant