Motion detection method, device, storage medium and electronic device
By judging the quantitative relationship of moving image blocks in the motion detection method, determining the scene type and starting the slow recording mode, the problem of low motion detection efficiency in the prior art is solved, and more efficient motion detection is achieved.
Patent Information
- Application Number
- CN202111133842.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-27
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2041-09-27
AI Technical Summary
The existing motion detection methods are high in computational complexity and time-consuming, resulting in inefficiency.
By judging the quantitative relationship between moving image blocks in the non-interested area and the area of interest, determine that the current scene is a global motion scene or a local motion scene, and start the slow recording mode.
It effectively determines whether there are moving objects in the current scene and starts the slow recording mode when motion is detected, which improves the efficiency of motion detection.
Smart Images

Figure CN113873097B_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to the field of video processing technology, and in particular to a motion detection method, device, storage medium and electronic equipment. [Background technology]
[0002] In the related art, motion detection methods are mainly divided into two categories: one is to use traditional methods, and the other is artificial intelligence (AI) recognition methods.
[0003] The traditional method determines whether there is a moving object in the scene based on the moving speed of the target object. First, the position data of the target object in two adjacent frames of images is obtained, and then the relative displacement of the target object is calculated based on the position data of the target object in the two adjacent frames of images. Finally, the moving speed of the target object is calculated based on the relative displacement of the target object. This makes the calculation of the moving speed of the target object more complex, the motion detection takes a long time, and the efficiency of motion detection is reduced.
[0004] The AI recognition method requires a large and comprehensive training set to be trained in order to obtain better motion detection results, which makes the motion detection time-consuming and reduces the efficiency of motion detection. [Summary of the invention]
[0005] In view of this, embodiments of the present invention provide a motion detection method, device, storage medium and electronic device to improve the efficiency of motion detection.
[0006] On the one hand, an embodiment of the present invention provides a motion detection method, including:
[0007] Determine whether the total number of motion image blocks in the non-interested region, the total number of image blocks in the non-interested region, the total number of motion image blocks in the image blocks in the interested region, and the total number of image blocks in the interested region satisfy the first condition or the second condition;
[0008] If it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, it is determined that the current scene is a global motion scene, and the slow recording mode is started;
[0009] If it is determined that the total number of motion image blocks in the acquired non-interest area, the total number of image blocks in the non-interest area, the total number of motion image blocks in the image blocks in the interest area and the total number of image blocks in the interest area meet the second condition, it is determined that the current scene is a local motion scene and the slow recording mode is started.
[0010] Optionally, it also includes:
[0011] If it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area do not satisfy the first condition and the second condition, judging whether the current scene is a global motion scene according to the total number of moving image blocks in the large image block;
[0012] If the current scene is determined to be a global motion scene, the slow recording mode is disabled.
[0013] Optionally, before determining whether the total number of motion image blocks in the non-interested region, the total number of image blocks in the non-interested region, the total number of motion image blocks in the image blocks in the interested region, and the total number of image blocks in the interested region meet the first condition or the second condition, the step includes:
[0014] According to the average brightness of the current frame image and the average brightness of the previous frame image, it is determined whether the current scene is a scene with illumination changes;
[0015] If the current scene is determined to be a scene with changing lighting, the slow recording mode is disabled;
[0016] If it is determined that the current scene is not a scene with changing lighting, the step of determining whether the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition or the second condition is continued.
[0017] Optionally, the first condition includes:
[0018] The first value is greater than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks acquired in the non-interest area, the second value is the product of the total number of image blocks acquired in the non-interest area and the set global motion image block high threshold, the third value is the total number of motion image blocks in the image blocks acquired in the interest area, and the fourth value is the product of the total number of image blocks acquired in the interest area and the set local motion image block threshold.
[0019] Optionally, the second condition includes:
[0020] The first value is less than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks acquired in the non-interest area, the second value is the product of the total number of image blocks acquired in the non-interest area and the set global motion image block high threshold, the third value is the total number of motion image blocks acquired in the interest area, and the fourth value is the product of the total number of image blocks acquired in the interest area and the set local motion image block threshold.
[0021] Optionally, judging whether the current scene is a global motion scene according to the total number of moving image blocks in the acquired large image block includes:
[0022] Determine whether the total number of moving image blocks in the acquired large image block is greater than a set global moving image block threshold;
[0023] If it is determined that the total number of moving image blocks in the acquired large image block is greater than the set global moving image block threshold, it is determined that the current scene is a global moving scene.
[0024] Optionally, judging whether the current scene is a scene with illumination changes according to the acquired average brightness of the current frame image and the average brightness of the previous frame image includes:
[0025] Determine whether the obtained fifth value is greater than the obtained sixth value, wherein the fifth value is the absolute value of the difference between the average brightness of the current frame image and the average brightness of the previous frame image, and the sixth value is the product value of the set illumination change threshold, the obtained width value of each image block, and the height value of each image block;
[0026] If it is determined that the fifth value is greater than the sixth value, it is determined that the current scene is a lighting change scene.
[0027] Optionally, the determining whether the total number of motion image blocks in the non-interested region, the total number of image blocks in the non-interested region, the total number of motion image blocks in the image blocks in the interested region, and the total number of image blocks in the interested region satisfy the first condition or the second condition comprises:
[0028] Generate an inter-frame difference of the image blocks in the non-interest area according to the brightness information of the image blocks in the non-interest area of the current frame image and the brightness information of the image blocks in the non-interest area of the previous frame image;
[0029] Determine whether the inter-frame difference of the image block of the non-interested region is greater than a set global motion threshold;
[0030] If it is determined that the inter-frame difference of the image block in the non-interest area is greater than the set global motion threshold, the image block in the non-interest area is marked as a motion image block;
[0031] According to the marked moving image blocks, the total number of moving image blocks in the non-interest region is counted.
[0032] Optionally, before determining whether the total number of motion image blocks in the non-interested region, the total number of image blocks in the non-interested region, the total number of motion image blocks in the image blocks in the interested region, and the total number of image blocks in the interested region meet the first condition or the second condition, the step further includes:
[0033] Generate an inter-frame difference of the image block of the region of interest according to the brightness information of the image block of the region of interest of the current frame image and the brightness information of the image block of the region of interest of the previous frame image;
[0034] Determine whether the inter-frame difference of the image block of the region of interest is greater than a set local motion threshold;
[0035] If it is determined that the inter-frame difference of the image block in the region of interest is greater than a set local motion threshold, marking the image block in the region of interest as a motion image block;
[0036] According to the marked moving image blocks, the total number of moving image blocks in the region of interest is counted.
[0037] Optionally, marking the image block of the region of interest as a motion image block comprises:
[0038] Dividing a first set number of image blocks of the acquired current frame image into a second set number of large image blocks;
[0039] generating a total number of moving image blocks in a large image block according to the total number of moving image blocks in the non-interested region and the total number of moving image blocks in the interested region;
[0040] Determining whether the total number of moving image blocks in the large image block is greater than a set global motion threshold;
[0041] If it is determined that the total number of moving image blocks in the large image block is greater than the set global motion threshold, marking the moving image blocks in the large image block as moving image blocks;
[0042] According to the marked moving image blocks, the total number of moving image blocks in the large image block is counted.
[0043] Optionally, before generating the frame difference of the image block of the non-interest area according to the brightness information of the image block of the non-interest area of the current frame image and the brightness information of the image block of the non-interest area of the previous frame image, the method includes:
[0044] Acquire a plurality of first channel values, a plurality of second channel values, and a plurality of third channel values of an image block of a non-interested region of a current frame image;
[0045] Generate a first channel mean, a second channel mean, and a third channel mean according to a plurality of first channel values, a plurality of second channel values, and a plurality of third channel values of an image block of a non-interested region of a current frame image;
[0046] Brightness information of an image block of a non-interested area of the current frame image is generated according to the first channel mean, the second channel mean, and the third channel mean.
[0047] Optionally, before generating the frame difference of the image block of the non-interest area according to the brightness information of the image block of the non-interest area of the current frame image and the brightness information of the image block of the non-interest area of the previous frame image, the step further includes:
[0048] Acquire a plurality of fourth channel values, a plurality of fifth channel values, and a plurality of sixth channel values of an image block of a non-interested region of a previous frame of image;
[0049] Generate a fourth channel mean, a fifth channel mean, and a sixth channel mean according to a plurality of fourth channel values, a plurality of fifth channel values, and a plurality of sixth channel values of an image block of a non-interested region of a previous frame of image;
[0050] Brightness information of an image block of a non-interested region of the previous frame image is generated according to the fourth channel mean, the fifth channel mean, and the sixth channel mean.
[0051] Optionally, before generating the frame difference of the image block of the region of interest according to the brightness information of the image block of the region of interest of the current frame image and the brightness information of the image block of the region of interest of the previous frame image, the method includes:
[0052] Acquire multiple seventh channel values, multiple eighth channel values, and multiple ninth channel values of an image block of an area of interest of a current frame image;
[0053] Generate a seventh channel mean, an eighth channel mean, and a ninth channel mean according to a plurality of seventh channel values, a plurality of eighth channel values, and a plurality of ninth channel values of an image block of an area of interest of a current frame image;
[0054] The brightness information of the image block of the region of interest of the current frame image is generated according to the seventh channel mean, the eighth channel mean and the ninth channel mean.
[0055] Optionally, before generating the frame difference of the image block of the region of interest according to the brightness information of the image block of the region of interest of the current frame image and the brightness information of the image block of the region of interest of the previous frame image, the method includes:
[0056] Acquire a plurality of tenth channel values, a plurality of eleventh channel values, and a plurality of twelfth channel values of an image block of an area of interest of a previous frame of image;
[0057] Generate a tenth channel mean, an eleventh channel mean, and a twelfth channel mean according to a plurality of tenth channel values, a plurality of eleventh channel values, and a plurality of twelfth channel values of an image block of an area of interest of a previous frame of image;
[0058] Brightness information of an image block of the region of interest of the previous frame image is generated according to the tenth channel mean, the eleventh channel mean, and the twelfth channel mean.
[0059] Optionally, the determining whether the current scene is a scene with illumination changes according to the acquired average brightness of the current frame image and the average brightness of the previous frame image comprises:
[0060] Dividing the acquired current frame image into a first set number of image blocks;
[0061] Acquire a plurality of thirteenth channel values, a plurality of fourteenth channel values, and a plurality of fifteenth channel values of each image block of the current frame image;
[0062] Calculate the thirteenth channel mean, the fourteenth channel mean and the fifteenth channel mean of each image block of the current frame image according to the multiple thirteenth channel values, the multiple fourteenth channel values and the multiple fifteenth channel values of each image block of the current frame image;
[0063] Generate brightness information of each image block of the current frame image according to the thirteenth channel mean, the fourteenth channel mean, and the fifteenth channel mean of each image block of the current frame image;
[0064] The average brightness of the current frame image is generated according to the brightness information of each image block of the current frame image.
[0065] Optionally, the determining whether the current scene is a scene with illumination changes according to the acquired average brightness of the current frame image and the average brightness of the previous frame image comprises:
[0066] Dividing the acquired last frame of image into a first set number of image blocks;
[0067] Acquire a plurality of sixteenth channel values, a plurality of seventeenth channel values, and a plurality of eighteenth channel values of each image block of a previous frame of image;
[0068] Calculate the sixteenth channel mean, the seventeenth channel mean and the eighteenth channel mean of each image block of the previous frame of image according to the multiple sixteenth channel values, the multiple seventeenth channel values and the multiple eighteenth channel values of each image block of the previous frame of image;
[0069] Generate brightness information of each image block of the previous frame of image according to the sixteenth channel mean, the seventeenth channel mean, and the eighteenth channel mean of each image block of the previous frame of image;
[0070] The average brightness of the previous frame of image is generated according to the brightness information of each image block of the previous frame of image.
[0071] On the other hand, an embodiment of the present invention provides a motion detection device, including:
[0072] The first judgment module is used to judge whether the total number of motion image blocks in the non-interest area, the total number of image blocks in the non-interest area, the total number of motion image blocks in the image blocks in the interest area, and the total number of image blocks in the interest area meet the first condition or the second condition; if it is judged that the total number of motion image blocks in the non-interest area, the total number of image blocks in the non-interest area, the total number of motion image blocks in the image blocks in the interest area, and the total number of image blocks in the interest area meet the first condition, the first determination module is triggered to determine that the current scene is a global motion scene, and the slow recording mode is started; if it is judged that the total number of motion image blocks in the non-interest area, the total number of image blocks in the non-interest area, the total number of motion image blocks in the image blocks in the interest area, and the total number of image blocks in the interest area meet the second condition, the second determination module is triggered to determine that the current scene is a local motion scene, and the slow recording mode is started.
[0073] On the other hand, an embodiment of the present invention provides a storage medium, including: the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above-mentioned motion detection method.
[0074] On the other hand, an embodiment of the present invention provides an electronic device, including a memory and a processor, wherein the memory is used to store information including program instructions, and the processor is used to control the execution of the program instructions, and is characterized in that the program instructions implement the steps of the above-mentioned motion detection method when loaded and executed by the processor.
[0075] In the technical solution of the motion detection method provided by the embodiment of the present invention, if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, then it is determined that the current scene is a global motion scene, and the slow recording mode is started; if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the second condition, then it is determined that the current scene is a local motion scene, and the slow recording mode is started. In the technical solution provided by the embodiment of the present invention, it is possible to effectively determine whether there is a moving object in the current scene. If it is determined that there is a moving object, the slow recording mode is started, thereby improving the efficiency of motion detection.
Brief Description of the Drawings
[0076] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0077] Figure 1 A flow chart of a motion detection method provided by an embodiment of the present invention;
[0078] Figure 2 A flowchart of another motion detection method provided by an embodiment of the present invention;
[0079] Figure 3 A schematic diagram of the structure of a motion detection device provided by an embodiment of the present invention;
[0080] Figure 4 A schematic diagram of an electronic device provided by an embodiment of the present invention. [Specific implementation method]
[0081] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0082] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0083] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0084] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0085] The embodiment of the present invention provides a motion detection method. Figure 1 A flow chart of a motion detection method provided by an embodiment of the present invention is as follows: Figure 1 As shown, the method includes:
[0086] Step 102, determine whether the total number of motion image blocks in the non-interest area, the total number of image blocks in the non-interest area, the total number of motion image blocks in the image blocks in the interest area, and the total number of image blocks in the interest area meet the first condition or the second condition. If the first condition is met, execute step 104; if the second condition is met, execute step 106.
[0087] In the embodiment of the present invention, the first condition includes:
[0088] The first value is greater than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks in the acquired non-interest region, the second value is the product of the total number of image blocks in the acquired non-interest region and the set global motion image block high threshold, the third value is the total number of motion image blocks in the acquired image blocks of the region of interest (Region Of Interest, ROI for short), and the fourth value is the product of the total number of image blocks in the acquired region of interest and the set local motion image block threshold.
[0089] In the embodiment of the present invention, the second condition includes:
[0090] The first value is less than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks acquired in the non-interest area, the second value is the product of the total number of image blocks acquired in the non-interest area and the set global motion image block high threshold, the third value is the total number of motion image blocks acquired in the interest area, and the fourth value is the product of the total number of image blocks acquired in the interest area and the set local motion image block threshold.
[0091] Step 104: determine that the current scene is a global motion scene, and start the slow recording mode, and the process ends.
[0092] In the embodiment of the present invention, if it is determined that the current scene is a global motion scene, it indicates that there is a large-area moving object in the shooting scene. For example, the large-area moving object is a large-area water flow.
[0093] Step 106: Determine that the current scene is a local motion scene, and start the slow recording mode.
[0094] In the embodiment of the present invention, if it is determined that the current scene is a local motion scene, it indicates that there is a moving object in the region of interest in the captured scene.
[0095] In the technical solution provided by the embodiment of the present invention, if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, then it is determined that the current scene is a global motion scene, and the slow recording mode is started; if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the second condition, then it is determined that the current scene is a local motion scene, and the slow recording mode is started. In the technical solution provided by the embodiment of the present invention, it is possible to effectively determine whether there is a moving object in the current scene. If it is determined that there is a moving object, the slow recording mode is started, thereby improving the efficiency of motion detection.
[0096] The embodiment of the present invention provides another motion detection method. Figure 2 A flowchart of another motion detection method provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the method includes:
[0097] Step 202: Divide the acquired current frame image into a first set number of image blocks.
[0098] In the embodiment of the present invention, the process before step 202 includes: in response to a recording instruction input by a user, acquiring image data at a set frame interval, wherein the image data includes a current frame image and a previous frame image.
[0099] In the embodiment of the present invention, the number of frames can be set according to actual conditions, and the number of frames is related to the frame rate of the image data.
[0100] In the embodiment of the present invention, the first set number can be set according to actual conditions. For example, the first set number is n*n.
[0101] Step 204 : Obtain a plurality of thirteenth channel values, a plurality of fourteenth channel values, and a plurality of fifteenth channel values of each image block of the current frame image.
[0102] In the embodiment of the present invention, each image block of the current frame image has a plurality of thirteenth channel values, a plurality of fourteenth channel values, and a plurality of fifteenth channel values.
[0103] The thirteenth channel value is a red (Red, referred to as R) channel value, the fourteenth channel value is a green (Green, referred to as G) channel value, and the fifteenth channel value is a blue (Blue, referred to as B) channel value.
[0104] Step 206 , calculating the thirteenth channel mean, the fourteenth channel mean and the fifteenth channel mean of each image block of the current frame image according to the multiple thirteenth channel values, the multiple fourteenth channel values and the multiple fifteenth channel values of each image block of the current frame image.
[0105] In the embodiment of the present invention, multiple thirteenth channel values are added to generate a sum of the thirteenth channel values, and the sum of the thirteenth channel values is divided by the number of the multiple thirteenth channel values to generate a thirteenth channel mean. For example, the thirteenth channel mean is recorded as blk_r[i][j], where i and j represent the row number and column number of the divided n×n image blocks, respectively.
[0106] The plurality of fourteenth channel values are added together to generate a sum of the fourteenth channel values, and the sum of the fourteenth channel values is divided by the number of the plurality of fourteenth channel values to generate a fourteenth channel mean value. For example, the fourteenth channel mean value is recorded as blk_g[i][j].
[0107] A plurality of fifteenth channel values are added together to generate a sum of the fifteenth channel values, and the sum of the fifteenth channel values is divided by the number of the plurality of fifteenth channel values to generate a fifteenth channel mean value. For example, the fifteenth channel mean value is recorded as blk_b[i][j].
[0108] Step 208: Generate brightness information of each image block of the current frame image according to the thirteenth channel mean, the fourteenth channel mean and the fifteenth channel mean of each image block of the current frame image.
[0109] Specifically, the thirteenth channel mean, the fourteenth channel mean and the fifteenth channel mean of each image block of the current frame image are calculated by the formula blk_y[i][j]=blk_r[i][j]+blk_g[i][j]+blk_b[i][j] to generate the brightness information of each image block of the current frame image. Wherein, blk_r[i][j] is the thirteenth channel mean, blk_g[i][j] is the fourteenth channel mean, blk_b[i][j] is the fifteenth channel mean, and blk_y[i][j] is the brightness information of each image block of the current frame image.
[0110] Step 210: Generate an average brightness of the current frame image according to the brightness information of each image block of the current frame image.
[0111] In this step, the brightness information of each image block of the current frame image is added and then divided by the number of image blocks in the current frame image to generate the average brightness of the current frame image.
[0112] Specifically, through the formula Calculate the brightness information of each image block of the current frame image to generate the average brightness of the current frame image. Where ave_y is the average brightness, blk_y[i][j] refers to the brightness information of the (i, j)th image block, and n refers to the fact that the entire frame image is divided into n parts horizontally and vertically. A frame image will be divided into n×n image blocks in total.
[0113] Step 212: Divide the acquired last frame of image into a first set number of image blocks.
[0114] Step 214 , obtaining a plurality of sixteenth channel values, a plurality of seventeenth channel values, and a plurality of eighteenth channel values of each image block of the previous frame of image.
[0115] In the embodiment of the present invention, each image block of the current frame image has a plurality of sixteenth channel values, a plurality of seventeenth channel values, and a plurality of eighteenth channel values.
[0116] Among them, the sixteenth channel value is the red (Red, referred to as R) channel value, the seventeenth channel value is the green (Green, referred to as G) channel value, and the eighteenth channel value is the blue (Blue, referred to as B) channel value.
[0117] Step 216, calculating the sixteenth channel mean, the seventeenth channel mean and the eighteenth channel mean of each image block of the previous frame image according to the multiple sixteenth channel values, the multiple seventeenth channel values and the multiple eighteenth channel values of each image block of the previous frame image.
[0118] Step 218: Generate brightness information of each image block of the previous frame of image according to the sixteenth channel mean, the seventeenth channel mean and the eighteenth channel mean of each image block of the previous frame of image.
[0119] Step 220: Generate the average brightness of the previous frame of image according to the brightness information of each image block of the previous frame of image.
[0120] In the embodiment of the present invention, the calculation method of step 212 to step 220 is the same as the calculation method of step 202 to step 210, and will not be repeated here.
[0121] Step 222 , judging whether the current scene is a scene of illumination change according to the average brightness of the current frame image and the average brightness of the previous frame image, if so, executing step 224 ; if not, executing step 226 .
[0122] Specifically, determine whether the obtained fifth value is greater than the obtained sixth value, wherein the fifth value is the absolute value of the difference between the average brightness of the current frame image and the average brightness of the previous frame image, and the sixth value is the product of the set illumination change threshold, the width value of each image block obtained, and the height value of each image block; if so, determine that the current scene is an illumination change scene, and execute step 224; if not, determine that the current scene is not an illumination change scene, and execute step 226.
[0123] Specifically, if abs(ave_y pre -ave_y cur )>ill_change×blk_width×blk_height, the current scene is judged to be a scene of illumination change. pre -ave_y cur ) is the fifth value, ill_change×blk_width×blk_height is the sixth value, ave_y pre is the average brightness of the previous frame, ave_y cur is the average brightness of the current frame image, ill_change is the illumination change threshold, blk_width is the width of each image block, and blk_height is the height of each image block.
[0124] In the embodiment of the present invention, the illumination change threshold can be set according to actual conditions.
[0125] Step 224, disable the slow recording mode, and the process ends.
[0126] Step 226: Acquire a plurality of first channel values, a plurality of second channel values, and a plurality of third channel values of an image block of a non-interested region of the current frame image.
[0127] In the embodiment of the present invention, the current frame image is divided into an area of interest and an area of no interest.
[0128] In the embodiment of the present invention, each image block of the non-interest region of the current frame image has a plurality of first channel values, a plurality of second channel values, and a plurality of third channel values.
[0129] The first channel value is a red (Red, R for short) channel value, the second channel value is a green (Green, G for short) channel value, and the third channel value is a blue (Blue, B for short) channel value.
[0130] Step 228: Generate a first channel mean, a second channel mean, and a third channel mean according to the multiple first channel values, the multiple second channel values, and the multiple third channel values of the image block of the non-interest area of the current frame image.
[0131] Step 230: Generate brightness information of an image block of a non-interested region of the current frame image according to the first channel mean, the second channel mean, and the third channel mean.
[0132] Step 232: Acquire a plurality of fourth channel values, a plurality of fifth channel values, and a plurality of sixth channel values of an image block of a non-interested region of a previous frame of image.
[0133] Step 234 , generating a fourth channel mean, a fifth channel mean, and a sixth channel mean according to a plurality of fourth channel values, a plurality of fifth channel values, and a plurality of sixth channel values of the image block of the non-interested region of the previous frame of image.
[0134] Step 236: Generate brightness information of the image block of the non-interested region of the previous frame image according to the fourth channel mean, the fifth channel mean, and the sixth channel mean.
[0135] In the embodiment of the present invention, the calculation method of step 226 to step 236 is the same as the calculation method of step 202 to step 210, and will not be repeated here.
[0136] Step 238 , obtaining a plurality of seventh channel values, a plurality of eighth channel values, and a plurality of ninth channel values of the image block of the region of interest of the current frame image.
[0137] In the embodiment of the present invention, each image block of the non-interest region of the current frame image has a plurality of seventh channel values, a plurality of eighth channel values, and a plurality of ninth channel values.
[0138] Among them, the seventh channel value is the red (Red, referred to as R) channel value, the eighth channel value is the green (Green, referred to as G) channel value, and the ninth channel value is the blue (Blue, referred to as B) channel value.
[0139] Step 240 , generating a seventh channel mean, an eighth channel mean and a ninth channel mean according to a plurality of seventh channel values, a plurality of eighth channel values and a plurality of ninth channel values of an image block of a region of interest of a current frame image.
[0140] Step 242: Generate brightness information of an image block of the region of interest of the current frame image according to the seventh channel mean, the eighth channel mean, and the ninth channel mean.
[0141] Step 244 , obtaining a plurality of tenth channel values, a plurality of eleventh channel values, and a plurality of twelfth channel values of the image block of the region of interest of the previous frame of image.
[0142] Step 246 , generating a tenth channel mean, an eleventh channel mean and a twelfth channel mean according to the plurality of tenth channel values, the plurality of eleventh channel values and the plurality of twelfth channel values of the image block of the region of interest of the previous frame of image.
[0143] Step 248: Generate brightness information of the image block of the region of interest of the previous frame image according to the tenth channel mean, the eleventh channel mean, and the twelfth channel mean.
[0144] In the embodiment of the present invention, the calculation method of step 238 to step 248 is the same as the calculation method of step 202 to step 210, and will not be repeated here.
[0145] Step 250 : Generate an inter-frame difference of the image blocks in the non-interest region according to the brightness information of the image blocks in the non-interest region of the current frame image and the brightness information of the image blocks in the non-interest region of the previous frame image.
[0146] Specifically, by the formula diff[i][j]=abs(blk_y cur [i][j]-blk_y pre [i][j]) Calculate the brightness information of the image blocks in the non-interested area of the current frame image and the brightness information of the image blocks in the non-interested area of the previous frame image to generate the inter-frame difference of the image blocks in the non-interested area. cur [i][j] is the brightness information of the image block in the non-interested area of the current frame image, blk_y pre [i][j] is the brightness information of the image block of the non-interest area of the previous frame image, and diff[i][j] is the inter-frame difference of the image block of the non-interest area.
[0147] Step 252 , determine whether the inter-frame difference of the image block of the non-interested area is greater than the set global motion threshold, if so, execute step 256 ; if not, execute step 254 .
[0148] In the embodiment of the present invention, the global motion threshold can be set according to actual conditions.
[0149] In the embodiment of the present invention, the image block weight of the image block in the non-interest area is less than 50%.
[0150] Specifically, through the formula The width value of each image block, the height value of each image block, the width value of the (i, j)th image block in the region of interest, and the height value of the (i, j)th image block in the region of interest are calculated to generate the image block weight. Among them, blk_w[i][j] is the image block weight, blk_width is the width value of each image block, blk_height is the height value of each image block, w_in[i][j] is the width value of the (i, j)th image block in the region of interest, and h_in[i][j] is the height value of the (i, j)th image block in the region of interest.
[0151] In the embodiment of the present invention, if it is determined that the inter-frame difference of the image block in the non-interest area is greater than the set global motion threshold, it indicates that the image block is a motion image block, and step 256 is executed; if it is determined that the inter-frame difference of the image block in the non-interest area is less than or equal to the set global motion threshold, it indicates that the image block is a non-motion image block, and step 254 is executed.
[0152] Step 254: Mark the image blocks in the non-interest area as non-motion image blocks.
[0153] Step 256: Mark the image blocks in the non-interest area as motion image blocks.
[0154] Step 258: Count the total number of motion image blocks in the non-interested region based on the marked motion image blocks.
[0155] In this step, the total number of motion image blocks in the non-interested region is recorded as num_exc.
[0156] Step 260 : Generate an inter-frame difference of the image blocks in the region of interest based on the brightness information of the image blocks in the region of interest in the current frame image and the brightness information of the image blocks in the region of interest in the previous frame image.
[0157] In the embodiment of the present invention, the calculation method of step 260 is the same as the calculation method of step 250, which will not be described again here.
[0158] Step 262 , determine whether the inter-frame difference of the image block in the region of interest is greater than the set local motion threshold, if so, execute step 266 ; if not, execute step 264 .
[0159] In the embodiment of the present invention, the local motion threshold can be set according to actual conditions.
[0160] In the embodiment of the present invention, the image block weight of the image block in the non-interest area is greater than 50%.
[0161] In the embodiment of the present invention, if it is determined that the inter-frame difference of the image block in the region of interest is greater than the set local motion threshold, it indicates that the image block is a motion image block, and step 266 is executed; if it is determined that the inter-frame difference of the image block in the region of interest is less than or equal to the set local motion threshold, it indicates that the image block is a non-motion image block, and step 264 is executed.
[0162] Step 264: Mark the image blocks in the region of interest as non-motion image blocks.
[0163] Step 266: Mark the image block in the region of interest as a motion image block.
[0164] Step 268: Count the total number of motion image blocks in the region of interest based on the marked motion image blocks.
[0165] In this step, the total number of motion image blocks in the counted region of interest is recorded as num_roi.
[0166] Step 270: Divide a first set number of image blocks of the acquired current frame image into a second set number of large image blocks.
[0167] In the embodiment of the present invention, the second set number can be set according to actual conditions. For example, the second set number is 4*4.
[0168] As an optional solution, the acquired n*n image blocks of the current frame image are divided into 4*4 large image blocks.
[0169] Step 272: Generate the total number of motion image blocks in the large image block according to the total number of motion image blocks in the non-interest region and the total number of motion image blocks in the interest region.
[0170] In this step, the total number of motion image blocks in the large image block is recorded according to the total number of motion image blocks in the non-interest area and the total number of motion image blocks in the interest area, and the total number of motion image blocks in the large image block is recorded as blk_num[p][q].
[0171] Step 274 , determine whether the total number of motion image blocks in the large image block is greater than the set global motion threshold, if so, execute step 278 ; if not, execute step 276 .
[0172] In the embodiment of the present invention, the global movement threshold can be set according to actual conditions.
[0173] In the embodiment of the present invention, if it is determined that the total number of moving image blocks in the large image block is greater than the set global motion threshold, it indicates that the image block is a moving image block, and step 278 is executed; if it is determined that the total number of moving image blocks in the large image block is less than or equal to the set global motion threshold, it indicates that the image block is a non-moving image block, and step 276 is executed.
[0174] Step 276: Mark the moving image blocks in the large image blocks as non-moving image blocks.
[0175] Step 278: Mark the motion image blocks in the large image blocks as moving image blocks.
[0176] Step 280: Count the total number of moving image blocks in the large image block according to the marked moving image blocks.
[0177] In this step, the total number of moving image blocks in the counted large image block is recorded as num_move.
[0178] Step 282, determine whether the total number of motion image blocks in the non-interest area, the total number of image blocks in the non-interest area, the total number of motion image blocks in the image blocks in the interest area, and the total number of image blocks in the interest area meet the first condition or the second condition. If the first condition is met, execute step 284; if the second condition is met, execute step 286; if the first condition and the second condition are not met, execute step 288.
[0179] In the embodiment of the present invention, the first condition includes:
[0180] The first value is greater than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks acquired in the non-interest area, the second value is the product of the total number of image blocks acquired in the non-interest area and the set global motion image block high threshold, the third value is the total number of motion image blocks in the image blocks acquired in the interest area, and the fourth value is the product of the total number of image blocks acquired in the interest area and the set local motion image block threshold.
[0181] In the embodiment of the present invention, the second condition includes:
[0182] The first value is less than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks acquired in the non-interest area, the second value is the product of the total number of image blocks acquired in the non-interest area and the set global motion image block high threshold, the third value is the total number of motion image blocks acquired in the interest area, and the fourth value is the product of the total number of image blocks acquired in the interest area and the set local motion image block threshold.
[0183] Step 284: determine that the current scene is a global motion scene, start the slow recording mode, and the process ends.
[0184] In the embodiment of the present invention, if it is determined that the current scene is a global motion scene, it indicates that there is a large-area moving object in the shooting scene. For example, the large-area moving object is a large-area water flow.
[0185] Step 286: determine that the current scene is a local motion scene, start the slow recording mode, and the process ends.
[0186] In the embodiment of the present invention, if it is determined that the current scene is a local motion scene, it indicates that there is a moving object in the region of interest in the captured scene.
[0187] Step 288 , judging whether the current scene is a global motion scene according to the total number of moving image blocks in the acquired large image block, if so, executing step 224 ; if not, executing step 202 .
[0188] Specifically, it is determined whether the total number of moving image blocks in the acquired large image block is greater than the set global moving image block threshold; if it is determined that the total number of moving image blocks in the acquired large image block is greater than the set global moving image block threshold, it is determined that the current scene is a global moving scene.
[0189] In an embodiment of the present invention, if it is determined that the current scene is a global motion scene, it indicates that there is no moving object in the shooting scene, but the shooting device is moving, and step 224 is executed; if it is determined that the current scene is not a global motion scene, it indicates that the current scene is not a global motion scene, and step 202 is executed.
[0190] In the embodiment of the present invention, when a moving object is detected, the motion detection is terminated and the slow recording mode is started. Otherwise, the process returns to step 202 to continue the motion detection until the user stops recording.
[0191] In the technical solution provided by the embodiment of the present invention, if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, then it is determined that the current scene is a global motion scene, and the slow recording mode is started; if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the second condition, then it is determined that the current scene is a local motion scene, and the slow recording mode is started. In the technical solution provided by the embodiment of the present invention, it is possible to effectively determine whether there is a moving object in the current scene. If it is determined that there is a moving object, the slow recording mode is started, thereby improving the efficiency of motion detection.
[0192] The technical solution provided by the embodiment of the present invention can effectively detect whether there is a moving object in the shooting picture of the electronic device, and the time complexity is relatively low, which meets the real-time requirements in this mode to a higher degree.
[0193] In the technical solution provided by the embodiment of the present invention, the Bayer image data stream collected by the CMOS image sensor can be used as input, and the Bayer data of adjacent frames can be counted and compared to determine whether there is a moving object in the current scene to confirm whether the electronic device has started the slow recording mode.
[0194] The technical solution provided by the embodiment of the present invention has a low algorithm complexity and does not need to process each frame of the image, which can meet the requirements of real-time detection to a higher degree. At the same time, the technical solution provided by the embodiment of the present invention supports the distinction between the existence of moving objects and global movement, which can effectively improve the user's recording experience.
[0195] An embodiment of the present invention provides a motion detection device. Figure 3 A schematic diagram of the structure of a motion detection device provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the device includes: a first judging module 11, a first determining module 12 and a second determining module 13.
[0196] The first judgment module 11 is used to judge whether the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition or the second condition; if it is judged that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, the first determination module 12 is triggered to determine that the current scene is a global motion scene, and the slow recording mode is started; if it is judged that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the second condition, the second determination module 13 is triggered to determine that the current scene is a local motion scene, and the slow recording mode is started.
[0197] In the embodiment of the present invention, the device further includes: a second determination module 14 .
[0198] The first judgment module 11 is also used to trigger the second judgment module 14 to judge whether the current scene is a global motion scene according to the total number of moving image blocks in the acquired large image block if it is judged that the total number of motion image blocks in the non-interest area, the total number of image blocks in the non-interest area, the total number of motion image blocks in the image blocks in the interest area and the total number of image blocks in the interest area do not meet the first condition and the second condition; if it is judged that the current scene is a global motion scene, the slow recording mode is disabled.
[0199] In the embodiment of the present invention, the device further includes: a third judgment module 15.
[0200] The third judgment module 15 is used to judge whether the current scene is a scene of lighting change based on the average brightness of the current frame image and the average brightness of the previous frame image; if it is judged that the current scene is a scene of lighting change, the slow recording mode is disabled; if it is judged that the current scene is not a scene of lighting change, the first judgment module 11 is triggered to continue to execute the step of judging whether the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the area of interest, and the total number of image blocks in the area of interest meet the first condition or the second condition.
[0201] In the embodiment of the present invention, the first condition includes:
[0202] The first value is greater than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks acquired in the non-interest area, the second value is the product of the total number of image blocks acquired in the non-interest area and the set global motion image block high threshold, the third value is the total number of motion image blocks in the image blocks acquired in the interest area, and the fourth value is the product of the total number of image blocks acquired in the interest area and the set local motion image block threshold.
[0203] In the embodiment of the present invention, the second condition includes:
[0204] The first value is less than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks acquired in the non-interest area, the second value is the product of the total number of image blocks acquired in the non-interest area and the set global motion image block high threshold, the third value is the total number of motion image blocks acquired in the interest area, and the fourth value is the product of the total number of image blocks acquired in the interest area and the set local motion image block threshold.
[0205] In the embodiment of the present invention, the second judgment module 14 is specifically used to judge whether the total number of moving image blocks in the acquired large image block is greater than the set global moving image block threshold; if it is judged that the total number of moving image blocks in the acquired large image block is greater than the set global moving image block threshold, it is judged that the current scene is a global moving scene.
[0206] In the embodiment of the present invention, the third judgment module 15 is specifically used to judge whether the acquired fifth value is greater than the acquired sixth value, wherein the fifth value is the absolute value of the difference between the average brightness of the current frame image acquired and the average brightness of the previous frame image, and the sixth value is the product value of the set illumination change threshold, the width value of each image block acquired, and the height value of each image block; if it is judged that the fifth value is greater than the sixth value, then it is judged that the current scene is an illumination change scene.
[0207] In the embodiment of the present invention, the device further includes: a first generating module 16 , a fourth determining module 17 , a first marking module 18 and a first statistical module 19 .
[0208] The first generating module 16 is used to generate the frame difference of the image block of the non-interest area according to the brightness information of the image block of the non-interest area in the current frame image and the brightness information of the image block of the non-interest area in the previous frame image.
[0209] The fourth judgment module 17 is used to judge whether the inter-frame difference of the image block in the non-interest area is greater than the set global motion threshold; if it is judged that the inter-frame difference of the image block in the non-interest area is greater than the set global motion threshold, the first marking module 18 is triggered to mark the image block in the non-interest area as a motion image block.
[0210] The first counting module 19 is used to count the total number of moving image blocks in the non-interested region according to the marked moving image blocks.
[0211] In the embodiment of the present invention, the device further includes: a second generating module 20 , a fifth judging module 21 , a second marking module 22 and a second counting module 23 .
[0212] The second generating module 20 is used to generate an inter-frame difference of the image blocks in the region of interest according to the brightness information of the image blocks in the region of interest in the current frame image and the brightness information of the image blocks in the region of interest in the previous frame image.
[0213] The fifth judgment module 21 is used to judge whether the inter-frame difference of the image block of the region of interest is greater than the set local motion threshold; if it is judged that the inter-frame difference of the image block of the region of interest is greater than the set local motion threshold, the second marking module 22 is triggered to mark the image block of the region of interest as a motion image block.
[0214] The second counting module 23 is used to count the total number of moving image blocks in the region of interest according to the marked moving image blocks.
[0215] In the embodiment of the present invention, the device further includes: a first dividing module 24 , a third generating module 25 , a sixth judging module 26 , a third marking module 27 and a third statistical module 28 .
[0216] The first division module 24 is used to divide a first set number of image blocks of the acquired current frame image into a second set number of large image blocks.
[0217] The third generating module 25 is used to generate the total number of moving image blocks in the large image block according to the total number of moving image blocks in the non-interest area and the total number of moving image blocks in the interest area.
[0218] The sixth judgment module 26 is used to judge whether the total number of motion image blocks in the large image block is greater than the set global motion threshold; if it is judged that the total number of motion image blocks in the large image block is greater than the set global motion threshold, the third marking module 27 is triggered to mark the motion image blocks in the large image block as moving image blocks.
[0219] The third counting module 28 is used to count the total number of moving image blocks in the large image block according to the marked moving image blocks.
[0220] In the embodiment of the present invention, the device further includes: a first acquisition module 29 , a fourth generation module 30 and a fifth generation module 31 .
[0221] The first acquisition module 29 is used to acquire a plurality of first channel values, a plurality of second channel values and a plurality of third channel values of an image block of a non-interested region of the current frame image.
[0222] The fourth generating module 30 is used to generate a first channel mean, a second channel mean and a third channel mean according to a plurality of first channel values, a plurality of second channel values and a plurality of third channel values of an image block of a non-interested region of the current frame image.
[0223] The fifth generating module 31 is used to generate brightness information of an image block of a non-interested area of the current frame image according to the first channel mean, the second channel mean and the third channel mean.
[0224] In the embodiment of the present invention, the device further includes: a second acquisition module 32 , a sixth generation module 33 and a seventh generation module 34 .
[0225] The second acquisition module 32 is used to acquire a plurality of fourth channel values, a plurality of fifth channel values and a plurality of sixth channel values of an image block of a non-interested region of a previous frame of image.
[0226] The sixth generating module 33 is used to generate a fourth channel mean, a fifth channel mean and a sixth channel mean according to a plurality of fourth channel values, a plurality of fifth channel values and a plurality of sixth channel values of an image block of a non-interested region of a previous frame of image.
[0227] The seventh generating module 34 is used to generate brightness information of the image block of the non-interested area of the previous frame image according to the fourth channel mean, the fifth channel mean and the sixth channel mean.
[0228] In the embodiment of the present invention, the device further includes: a third acquisition module 35 , an eighth generation module 36 and a ninth generation module 37 .
[0229] The third acquisition module 35 is used to acquire a plurality of seventh channel values, a plurality of eighth channel values, and a plurality of ninth channel values of an image block of a region of interest of a current frame image.
[0230] The eighth generating module 36 is used to generate a seventh channel mean, an eighth channel mean and a ninth channel mean according to a plurality of seventh channel values, a plurality of eighth channel values and a plurality of ninth channel values of the image block of the region of interest of the current frame image.
[0231] The ninth generating module 37 is used to generate brightness information of an image block of the region of interest of the current frame image according to the seventh channel mean, the eighth channel mean and the ninth channel mean.
[0232] In the embodiment of the present invention, the device further includes: a fourth acquisition module 38 , a tenth generation module 39 and an eleventh generation module 40 .
[0233] The fourth acquisition module 38 is used to acquire a plurality of tenth channel values, a plurality of eleventh channel values, and a plurality of twelfth channel values of the image block of the region of interest of the previous frame of image.
[0234] The tenth generating module 39 is used to generate a tenth channel mean, an eleventh channel mean and a twelfth channel mean according to a plurality of tenth channel values, a plurality of eleventh channel values and a plurality of twelfth channel values of the image block of the region of interest of the previous frame image.
[0235] The eleventh generating module 40 is used to generate brightness information of an image block of the region of interest of the previous frame image according to the tenth channel mean, the eleventh channel mean and the twelfth channel mean.
[0236] In the embodiment of the present invention, the device further includes: a second dividing module 41 , a fifth acquiring module 42 , a first calculating module 43 , a twelfth generating module 44 and a thirteenth generating module 45 .
[0237] The second division module 41 is used to divide the acquired current frame image into a first set number of image blocks.
[0238] The fifth acquisition module 42 is used to acquire a plurality of thirteenth channel values, a plurality of fourteenth channel values and a plurality of fifteenth channel values of each image block of the current frame image.
[0239] The first calculation module 43 is used to calculate the thirteenth channel mean, the fourteenth channel mean and the fifteenth channel mean of each image block of the current frame image according to multiple thirteenth channel values, multiple fourteenth channel values and multiple fifteenth channel values of each image block of the current frame image.
[0240] The twelfth generating module 44 is used to generate brightness information of each image block of the current frame image according to the thirteenth channel mean value, the fourteenth channel mean value and the fifteenth channel mean value of each image block of the current frame image.
[0241] The thirteenth generating module 45 is used to generate the average brightness of the current frame image according to the brightness information of each image block of the current frame image.
[0242] In the embodiment of the present invention, the device further includes: a third dividing module 46 , a sixth acquiring module 47 , a second calculating module 48 , a fourteenth generating module 49 and a fifteenth generating module 50 .
[0243] The third division module 46 is used to divide the acquired last frame image into a first set number of image blocks.
[0244] The sixth acquisition module 47 is used to acquire a plurality of sixteenth channel values, a plurality of seventeenth channel values and a plurality of eighteenth channel values of each image block of the previous frame of image.
[0245] The second calculation module 48 is used to calculate the sixteenth channel mean, the seventeenth channel mean and the eighteenth channel mean of each image block of the previous frame image according to multiple sixteenth channel values, multiple seventeenth channel values and multiple eighteenth channel values of each image block of the previous frame image.
[0246] The fourteenth generating module 49 is used to generate the brightness information of each image block of the previous frame image according to the sixteenth channel mean, the seventeenth channel mean and the eighteenth channel mean of each image block of the previous frame image.
[0247] The fifteenth generating module 50 is used to generate the average brightness of the previous frame of image according to the brightness information of each image block of the previous frame of image.
[0248] In the technical solution provided by the embodiment of the present invention, if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, then it is determined that the current scene is a global motion scene, and the slow recording mode is started; if it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the second condition, then it is determined that the current scene is a local motion scene, and the slow recording mode is started. In the technical solution provided by the embodiment of the present invention, it is possible to effectively determine whether there is a moving object in the current scene. If it is determined that there is a moving object, the slow recording mode is started, thereby improving the efficiency of motion detection.
[0249] The motion detection device provided in this embodiment can be used to achieve the above Figure 1 and Figure 2 For the motion detection method in, the specific description can be found in the above-mentioned embodiment of the motion detection method, which will not be repeated here.
[0250] An embodiment of the present invention provides a storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the steps of the embodiment of the above-mentioned motion detection method. For a specific description, please refer to the embodiment of the above-mentioned motion detection method.
[0251] An embodiment of the present invention provides an electronic device, including a memory and a processor, the memory is used to store information including program instructions, the processor is used to control the execution of the program instructions, and when the program instructions are loaded and executed by the processor, the steps of the embodiment of the above-mentioned motion detection method are implemented. For a specific description, please refer to the embodiment of the above-mentioned motion detection method.
[0252] Figure 4 Schematic diagram of an electronic device provided by an embodiment of the present invention. Figure 4 As shown, the electronic device 60 of this embodiment includes: a processor 61, a memory 62, and a computer program 63 stored in the memory 62 and executable on the processor 61. When the computer program 63 is executed by the processor 61, the motion detection method in the embodiment is implemented. To avoid repetition, it is not described one by one here. Alternatively, when the computer program is executed by the processor 61, the functions of each model / unit in the motion detection device in the embodiment are implemented. To avoid repetition, it is not described one by one here.
[0253] The electronic device 60 includes, but is not limited to, a processor 61 and a memory 62. Those skilled in the art will appreciate that Figure 4 It is only an example of the electronic device 60 and does not constitute a limitation of the electronic device 60. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0254] The processor 61 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0255] The memory 62 may be an internal storage unit of the electronic device 60, such as a hard disk or memory of the electronic device 60. The memory 62 may also be an external storage device of the electronic device 60, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 60. Further, the memory 62 may also include both an internal storage unit of the electronic device 60 and an external storage device. The memory 62 is used to store computer programs and other programs and data required by the electronic device. The memory 62 may also be used to temporarily store data that has been output or is to be output.
[0256] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0257] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0258] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0259] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0260] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (Processor) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0261] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A motion detection method, It is characterized in that include: Determine whether the total number of motion image blocks in the non-interested region, the total number of image blocks in the non-interested region, the total number of motion image blocks in the image blocks in the interested region, and the total number of image blocks in the interested region satisfy the first condition or the second condition; If it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, it is determined that the current scene is a global motion scene, and the slow recording mode is started; If it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the second condition, it is determined that the current scene is a local motion scene, and the slow recording mode is started; The first condition includes: The first value is greater than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks in the acquired non-interested region, the second value is the product of the total number of image blocks in the acquired non-interested region and the set global motion image block high threshold, the third value is the total number of motion image blocks in the acquired image blocks in the interested region, and the fourth value is the product of the total number of image blocks in the acquired interested region and the set local motion image block threshold; The second condition includes: The first value is less than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks in the non-interested region obtained, the second value is the product of the total number of image blocks in the non-interested region obtained and the set global motion image block high threshold, the third value is the total number of motion image blocks in the interested region obtained, and the fourth value is the product of the total number of image blocks in the interested region obtained and the set local motion image block threshold; The step of determining whether the total number of motion image blocks in the non-interested region, the total number of image blocks in the non-interested region, the total number of motion image blocks in the image blocks in the interested region, and the total number of image blocks in the interested region meet the first condition or the second condition comprises: Generate an inter-frame difference of the image blocks in the non-interest area according to the brightness information of the image blocks in the non-interest area of the current frame image and the brightness information of the image blocks in the non-interest area of the previous frame image; Determine whether the inter-frame difference of the image block of the non-interested region is greater than a set global motion threshold; If it is determined that the inter-frame difference of the image block in the non-interest area is greater than the set global motion threshold, the image block in the non-interest area is marked as a motion image block; According to the marked moving image blocks, counting the total number of moving image blocks in the non-interested region; Before determining whether the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition or the second condition, the method further includes: Generate an inter-frame difference of the image block of the region of interest according to the brightness information of the image block of the region of interest of the current frame image and the brightness information of the image block of the region of interest of the previous frame image; Determine whether the inter-frame difference of the image block of the region of interest is greater than a set local motion threshold; If it is determined that the inter-frame difference of the image block in the region of interest is greater than a set local motion threshold, marking the image block in the region of interest as a motion image block; According to the marked moving image blocks, the total number of moving image blocks in the region of interest is counted.
2. The method according to claim 1, It is characterized in that Also includes: If it is determined that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area do not satisfy the first condition and the second condition, judging whether the current scene is a global motion scene according to the total number of moving image blocks in the large image block; If the current scene is determined to be a global motion scene, the slow recording mode is disabled.
3. The method according to claim 1, It is characterized in that Before determining whether the total number of motion image blocks in the non-interested region, the total number of image blocks in the non-interested region, the total number of motion image blocks in the image blocks in the interested region, and the total number of image blocks in the interested region meet the first condition or the second condition, the method comprises: According to the average brightness of the current frame image and the average brightness of the previous frame image, it is determined whether the current scene is a scene with illumination changes; If the current scene is determined to be a scene with changing lighting, the slow recording mode is disabled; If it is determined that the current scene is not a scene with changing lighting, the step of determining whether the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition or the second condition is continued.
4. The method according to claim 2, It is characterized in that The determining whether the current scene is a global motion scene according to the total number of moving image blocks in the acquired large image block includes: Determine whether the total number of moving image blocks in the acquired large image block is greater than a set global moving image block threshold; If it is determined that the total number of moving image blocks in the acquired large image block is greater than the set global moving image block threshold, it is determined that the current scene is a global moving scene.
5. The method according to claim 3, It is characterized in that The step of determining whether the current scene is a scene with illumination changes according to the average brightness of the current frame image and the average brightness of the previous frame image obtained includes: Determine whether the obtained fifth value is greater than the obtained sixth value, wherein the fifth value is the absolute value of the difference between the average brightness of the current frame image and the average brightness of the previous frame image, and the sixth value is the product value of the set illumination change threshold, the obtained width value of each image block, and the height value of each image block; If it is determined that the fifth value is greater than the sixth value, it is determined that the current scene is a lighting change scene.
6. The method according to claim 1, It is characterized in that The step of counting the total number of moving image blocks in the region of interest according to the marked moving image blocks includes: Dividing a first set number of image blocks of the acquired current frame image into a second set number of large image blocks; generating a total number of moving image blocks in a large image block according to the total number of moving image blocks in the non-interested region and the total number of moving image blocks in the interested region; Determining whether the total number of moving image blocks in the large image block is greater than a set global motion threshold; If it is determined that the total number of moving image blocks in the large image block is greater than the set global motion threshold, marking the moving image blocks in the large image block as moving image blocks; According to the marked moving image blocks, the total number of moving image blocks in the large image block is counted.
7. The method according to claim 1, It is characterized in that Before generating the frame difference of the image block of the non-interest area according to the brightness information of the image block of the non-interest area of the current frame image and the brightness information of the image block of the non-interest area of the previous frame image, the method includes: Acquire a plurality of first channel values, a plurality of second channel values, and a plurality of third channel values of an image block of a non-interested region of a current frame image; Generate a first channel mean, a second channel mean, and a third channel mean according to a plurality of first channel values, a plurality of second channel values, and a plurality of third channel values of an image block of a non-interested region of a current frame image; Brightness information of an image block of a non-interested area of the current frame image is generated according to the first channel mean, the second channel mean, and the third channel mean.
8. The method according to claim 1, It is characterized in that Before generating the inter-frame difference of the image blocks in the non-interest area according to the brightness information of the image blocks in the non-interest area of the current frame image and the brightness information of the image blocks in the non-interest area of the previous frame image, the method further comprises: Acquire a plurality of fourth channel values, a plurality of fifth channel values, and a plurality of sixth channel values of an image block of a non-interested region of a previous frame of image; Generate a fourth channel mean, a fifth channel mean, and a sixth channel mean according to a plurality of fourth channel values, a plurality of fifth channel values, and a plurality of sixth channel values of an image block of a non-interested region of a previous frame of image; Brightness information of an image block of a non-interested region of the previous frame image is generated according to the fourth channel mean, the fifth channel mean, and the sixth channel mean.
9. The method according to claim 1, It is characterized in that Before generating the frame difference of the image block of the region of interest according to the brightness information of the image block of the region of interest of the current frame image and the brightness information of the image block of the region of interest of the previous frame image, the method includes: Acquire multiple seventh channel values, multiple eighth channel values, and multiple ninth channel values of an image block of an area of interest of a current frame image; Generate a seventh channel mean, an eighth channel mean, and a ninth channel mean according to a plurality of seventh channel values, a plurality of eighth channel values, and a plurality of ninth channel values of an image block of an area of interest of a current frame image; The brightness information of the image block of the region of interest of the current frame image is generated according to the seventh channel mean, the eighth channel mean and the ninth channel mean.
10. The method according to claim 1, It is characterized in that Before generating the frame difference of the image block of the region of interest according to the brightness information of the image block of the region of interest of the current frame image and the brightness information of the image block of the region of interest of the previous frame image, the method includes: Acquire a plurality of tenth channel values, a plurality of eleventh channel values, and a plurality of twelfth channel values of an image block of an area of interest of a previous frame of image; Generate a tenth channel mean, an eleventh channel mean, and a twelfth channel mean according to a plurality of tenth channel values, a plurality of eleventh channel values, and a plurality of twelfth channel values of an image block of an area of interest of a previous frame of image; Brightness information of an image block of the region of interest of the previous frame image is generated according to the tenth channel mean, the eleventh channel mean, and the twelfth channel mean.
11. The method according to claim 3, It is characterized in that The step of determining whether the current scene is a scene with illumination changes according to the obtained average brightness of the current frame image and the average brightness of the previous frame image comprises: Dividing the acquired current frame image into a first set number of image blocks; Acquire a plurality of thirteenth channel values, a plurality of fourteenth channel values, and a plurality of fifteenth channel values of each image block of the current frame image; Calculate the thirteenth channel mean, the fourteenth channel mean and the fifteenth channel mean of each image block of the current frame image according to the multiple thirteenth channel values, the multiple fourteenth channel values and the multiple fifteenth channel values of each image block of the current frame image; Generate brightness information of each image block of the current frame image according to the thirteenth channel mean, the fourteenth channel mean, and the fifteenth channel mean of each image block of the current frame image; The average brightness of the current frame image is generated according to the brightness information of each image block of the current frame image.
12. The method according to claim 3, It is characterized in that The step of determining whether the current scene is a scene with illumination changes according to the obtained average brightness of the current frame image and the average brightness of the previous frame image comprises: Dividing the acquired last frame of image into a first set number of image blocks; Acquire a plurality of sixteenth channel values, a plurality of seventeenth channel values, and a plurality of eighteenth channel values of each image block of a previous frame of image; Calculate the sixteenth channel mean, the seventeenth channel mean and the eighteenth channel mean of each image block of the previous frame of image according to the multiple sixteenth channel values, the multiple seventeenth channel values and the multiple eighteenth channel values of each image block of the previous frame of image; Generate brightness information of each image block of the previous frame of image according to the sixteenth channel mean, the seventeenth channel mean, and the eighteenth channel mean of each image block of the previous frame of image; The average brightness of the previous frame of image is generated according to the brightness information of each image block of the previous frame of image.
13. A motion detection device, It is characterized in that include: A first judgment module is used to judge whether the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition or the second condition; if it is judged that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the first condition, then the first determination module is triggered to determine that the current scene is a global motion scene, and the slow recording mode is started; if it is judged that the total number of motion image blocks in the non-interested area, the total number of image blocks in the non-interested area, the total number of motion image blocks in the image blocks in the interested area, and the total number of image blocks in the interested area meet the second condition, then the second determination module is triggered to determine that the current scene is a local motion scene, and the slow recording mode is started; The first condition includes: The first value is greater than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks in the acquired non-interested region, the second value is the product of the total number of image blocks in the acquired non-interested region and the set global motion image block high threshold, the third value is the total number of motion image blocks in the acquired image blocks in the interested region, and the fourth value is the product of the total number of image blocks in the acquired interested region and the set local motion image block threshold; The second condition includes: The first value is less than the second value and the third value is greater than the fourth value, the first value is the total number of motion image blocks in the non-interested region obtained, the second value is the product of the total number of image blocks in the non-interested region obtained and the set global motion image block high threshold, the third value is the total number of motion image blocks in the interested region obtained, and the fourth value is the product of the total number of image blocks in the interested region obtained and the set local motion image block threshold; Also includes: A first generating module, used for generating an inter-frame difference of an image block in a non-interest region according to brightness information of an image block in a non-interest region of a current frame image and brightness information of an image block in a non-interest region of a previous frame image; a fourth judging module, configured to judge whether the inter-frame difference of the image block of the non-interest region is greater than a set global motion threshold; if it is judged that the inter-frame difference of the image block of the non-interest region is greater than the set global motion threshold, triggering the first marking module to mark the image block of the non-interest region as a motion image block; A first statistical module, used for counting the total number of motion image blocks in the non-interested region according to the marked motion image blocks; Also includes: A second generating module, used for generating an inter-frame difference of the image blocks of the region of interest according to the brightness information of the image blocks of the region of interest of the current frame image and the brightness information of the image blocks of the region of interest of the previous frame image; a fifth judging module, configured to judge whether the inter-frame difference of the image block of the region of interest is greater than a set local motion threshold; if it is judged that the inter-frame difference of the image block of the region of interest is greater than the set local motion threshold, triggering the second marking module to mark the image block of the region of interest as a motion image block; The second statistical module is used to count the total number of motion image blocks in the region of interest according to the marked motion image blocks.
14. A storage medium, It is characterized in that include: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute a motion detection method according to any one of claims 1 to 12.
15. An electronic device comprising a memory and a processor, wherein the memory is used to store information including program instructions, and the processor is used to control the execution of the program instructions. It is characterized in that When the program instructions are loaded and executed by the processor, the steps of a motion detection method according to any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Electronic device for obtaining images by controlling frame rate for external moving object through point of interest, and operating method thereof
US20200077019A1
Live video processing method, apparatus and device, and computer readable medium
WO2018076614A1