Image-based scene detection method and device, medium and electronic equipment

Through the image-based scene detection method, the comparison of gray-scale feature values ​​and scene recognition thresholds is used to solve the problem of high investment cost in the existing technology, and realize scene detection that simplifies operations and reduces costs, and is suitable for indoor and outdoor scenes. Promote quickly.

CN118608796APending Publication Date: 2024-09-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410613486.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-16
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing scene detection technology relies on a large amount of annotated data and high-precision sensors, resulting in high investment costs and difficulty in rapid promotion and popularization.

Method used

The image-based scene detection method is used to extract features of the image to be tested, obtain gray-scale distribution information, determine the target pixel set, and compare the gray-scale feature values ​​with the scene recognition threshold to achieve scene detection. This method simplifies the operation process, reduces costs, and is suitable for indoor and outdoor scene detection.

Benefits of technology

While ensuring detection accuracy, it lowers the application threshold of scene detection, simplifies the operation process, is suitable for various application scenarios, and promotes the rapid promotion and popularization of scene detection technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118608796A
    Figure CN118608796A
Patent Text Reader

Abstract

The invention provides an image-based scene detection method, an image-based scene detection device, a computer readable storage medium and electronic equipment, and is applied to the technical field of scene recognition. The method comprises the following steps: performing feature extraction on a to-be-detected image to obtain gray scale distribution information of pixels in the to-be-detected image; according to the gray scale distribution information, determining pixels of which gray scale values meet a preset condition, and obtaining a target pixel set; according to the gray-scale values of the pixels in the target pixel set, determining the gray-scale characteristic value of the image to be detected; and comparing the gray scale characteristic value of the image to be detected with a scene identification threshold value to obtain a scene detection result of the image to be detected, wherein the scene recognition threshold value is determined according to the gray scale feature values of the images in different scenes. According to the scheme provided by the invention, under the condition that the detection accuracy is guaranteed, the operation process is simple and easy to implement, and the input cost is relatively low.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of scene recognition technology, and in particular to an image-based scene detection method, an image-based scene detection device, a computer-readable storage medium, and an electronic device. Background Art

[0002] Scene detection plays a vital role in the process of computer systems understanding and parsing image content. For example, scene detection can be applied to biological detection, unmanned driving and other fields. It can help computer systems better understand, identify and adapt to different environments, so as to make corresponding adjustments and countermeasures, and improve the response speed and accuracy of the system.

[0003] In the related technologies, indoor and outdoor scene detection often relies on a large amount of labeled data for training, or relies on complex technologies such as high-precision sensors. Therefore, the scene detection solutions provided by the related technologies have the problem of high investment costs and are not suitable for rapid promotion and popularization. Summary of the invention

[0004] The present application provides an image-based scene detection method, an image-based scene detection device, a computer-readable storage medium, and an electronic device, which can ensure detection accuracy while having a simple and easy operation process and low investment cost, thereby lowering the application threshold of the scene detection solution and facilitating the rapid promotion and popularization of the scene detection solution.

[0005] In a first aspect, the present application provides an image-based scene detection method, the method comprising: performing feature extraction on an image to be tested to obtain grayscale distribution information of pixels in the image to be tested; based on the grayscale distribution information, determining pixels whose grayscale values ​​meet preset conditions to obtain a target pixel set; based on the grayscale values ​​of pixels in the target pixel set, determining grayscale characteristic values ​​of the image to be tested; and, comparing the grayscale characteristic values ​​of the image to be tested with a scene recognition threshold to obtain a scene detection result of the image to be tested; wherein the scene recognition threshold is determined based on the grayscale characteristic values ​​of images under different scenes.

[0006] In an exemplary embodiment, based on the above scheme, the image-based scene detection method also includes: acquiring sample images under N scenes, wherein N is an integer greater than 1; calculating the i-th grayscale eigenvalue corresponding to the i-th scene based on the sample image under the i-th scene, wherein i is a positive integer less than N; and determining the i-th scene recognition threshold based on the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue; wherein the i-th scene recognition threshold is used to compare with the grayscale eigenvalue corresponding to the image to be tested to determine whether the image to be tested belongs to the i+1-th scene or the i-th scene.

[0007] In an exemplary embodiment, based on the above scheme, the above i-th scene includes M sub-scenes; the sample image under the above i-th scene includes M sub-sample images corresponding to the M sub-scenes, where M is an integer greater than 1;

[0008] The above-mentioned calculating the i-th grayscale eigenvalue corresponding to the i-th scene according to the sample image under the i-th scene includes: calculating the sub-grayscale eigenvalues ​​corresponding to the sub-sample images under the i-th scene respectively to obtain M sub-grayscale eigenvalues; and, determining the grayscale eigenvalue corresponding to the i-th scene according to the M sub-grayscale eigenvalues; wherein, the above-mentioned determining the grayscale eigenvalue corresponding to the i-th scene according to the M sub-grayscale eigenvalues ​​includes: determining the j-th weights corresponding to the M sub-scenes under the i-th scene respectively, wherein j is a positive integer not greater than M; performing weighted processing on the sub-grayscale eigenvalues ​​corresponding to the j-th sub-scene by the j-th weight; and, determining the grayscale eigenvalue corresponding to the i-th scene according to the sub-grayscale eigenvalues ​​after the weighted processing.

[0009] In an exemplary embodiment, based on the above scheme, the i-th scene recognition threshold is determined according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue, including: determining the i-th interval, wherein the upper limit value of the i-th interval is the grayscale eigenvalue corresponding to the i+1-th scene, and the lower limit value of the i-th interval is the grayscale eigenvalue corresponding to the i-th scene; and, determining the i-th scene recognition threshold according to the i-th interval, wherein the i-th scene recognition threshold belongs to the i-th interval.

[0010] In an exemplary embodiment, based on the above scheme, after determining the i-th scene recognition threshold according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue, the above method also includes: determining the i-th scene switching high threshold corresponding to the situation where the i-th scene switches to the i+1-th scene; and, determining the i-th scene switching low threshold corresponding to the situation where the i+1-th scene switches to the i-th scene; wherein the i-th scene switching high threshold is greater than the i-th scene switching low threshold, and the i-th scene recognition threshold is greater than the i-th scene switching high threshold.

[0011] In an exemplary embodiment, based on the above scheme, the above determination of the i-th scene switching high threshold corresponding to the case where the i-th scene is switched to the i+1-th scene includes: obtaining a plurality of first sample images corresponding to the case where the i-th scene is switched to the i+1-th scene; obtaining first sample grayscale feature values ​​corresponding to the first sample images; and determining the i-th scene switching high threshold according to the statistical value of the first sample grayscale feature values;

[0012] The above-mentioned determination of the i-th scene switching low threshold corresponding to the situation where the i+1-th scene switches to the i-th scene includes: obtaining a plurality of second sample images corresponding to the situation where the i+1-th scene switches to the i-th scene; obtaining second sample grayscale feature values ​​corresponding to the second sample images; and determining the i-th scene switching low threshold according to the statistical value of the second sample grayscale feature values; wherein the difference between the i-th scene switching high threshold and the i-th scene switching low threshold is greater than a preset value.

[0013] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes; the sample images in the indoor scenes belong to a first image set consisting of sub-sample images corresponding to P indoor sub-scenes, and the sample images in the outdoor scenes belong to a second image set consisting of sub-sample images corresponding to Q outdoor sub-scenes, where P and Q are positive integers;

[0014] The calculating, based on the sample image under the i-th scene, the i-th grayscale eigenvalue corresponding to the i-th scene includes: calculating P sub-grayscale eigenvalues ​​corresponding to the P sub-sample images in the first image set, and determining the grayscale eigenvalue corresponding to the indoor scene based on the P sub-grayscale eigenvalues;

[0015] The above-mentioned determining the i-th scene recognition threshold based on the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue includes: determining a first interval, wherein the upper boundary value of the above-mentioned first interval is the grayscale eigenvalue corresponding to the outdoor scene, and the lower boundary value of the above-mentioned first interval is the grayscale eigenvalue corresponding to the indoor scene; and determining the indoor and outdoor scene recognition thresholds based on the above-mentioned first interval, wherein the above-mentioned indoor and outdoor scene recognition thresholds belong to the above-mentioned first interval.

[0016] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes; after determining the i-th scene recognition threshold according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue, the method further includes: determining a first scene switching threshold corresponding to the situation where the indoor scene switches to the outdoor scene; and determining a second scene switching threshold corresponding to the situation where the outdoor scene switches to the indoor scene; wherein the first scene switching threshold is greater than the second scene switching low threshold, and the indoor and outdoor scene recognition threshold is greater than the first scene switching high threshold.

[0017] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes, and the i-th scene recognition threshold is an indoor and outdoor scene recognition threshold;

[0018] The above-mentioned comparing the grayscale feature value of the above-mentioned image to be tested with the scene recognition threshold to obtain the scene detection result of the above-mentioned image to be tested includes: comparing the grayscale feature value of the above-mentioned image to be tested with the above-mentioned indoor and outdoor scene recognition threshold; if the grayscale feature value of the above-mentioned image to be tested is greater than the above-mentioned indoor and outdoor scene recognition threshold, the scene detection result is that the above-mentioned image to be tested belongs to the outdoor scene; if the grayscale feature value of the above-mentioned image to be tested is less than or equal to the above-mentioned indoor and outdoor scene recognition threshold, the scene detection result is that the above-mentioned image to be tested belongs to the indoor scene.

[0019] In an exemplary embodiment, based on the above solution, before acquiring the sample images under N scenes, the method further includes: determining the identification object corresponding to the identification occasion according to the identification occasion;

[0020] The obtaining of sample images in N scenes includes: obtaining sample images of the same type of recognition object in N scenes respectively;

[0021] After determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value, the method further includes: determining a first association relationship between the i-th scene recognition threshold and a corresponding recognition occasion;

[0022] Before comparing the grayscale characteristic value of the image to be tested with the scene recognition threshold, the method further includes: determining a current recognition scenario; and, based on the current recognition scenario, obtaining a scene recognition threshold having a first correlation with the current recognition scenario for comparison with the grayscale characteristic value of the image to be tested.

[0023] In an exemplary embodiment, based on the above scheme, there is a second association relationship between the target recognition occasion and the target recognition object, wherein the scene recognition threshold having the first association relationship with the above target recognition occasion is determined with respect to a sample image of the above target recognition object;

[0024] Before the feature extraction is performed on the image to be tested, the method further includes: determining a current recognition scenario; determining a current recognition object having a second association relationship with the current recognition scenario based on the current recognition scenario; and determining whether the image to be tested contains the current recognition object; wherein, in the case that the image to be tested contains the current recognition object, performing the step of feature extraction on the image to be tested; in the case that the image to be tested does not contain the current recognition object, reacquiring the image to be tested; wherein, the image to be tested and the sample image used to determine the scene recognition threshold are both infrared images.

[0025] In an exemplary embodiment, based on the above scheme, the above-mentioned determination of pixels whose grayscale values ​​meet preset conditions according to the above-mentioned grayscale distribution information to obtain a target pixel set includes: determining the total range of pixel grayscales in the above-mentioned image to be tested according to the above-mentioned grayscale distribution information; and determining a target range from the above-mentioned total range, wherein the grayscale values ​​of pixels in the above-mentioned target range meet preset conditions, wherein the grayscale value of the pixel under the preset condition is greater than the grayscale value of other pixels in the above-mentioned total range except for the above-mentioned target range, or the grayscale value of the pixel under the preset condition is less than the grayscale value of other pixels in the above-mentioned total range except for the above-mentioned target range;

[0026] The above-mentioned determining the grayscale characteristic value of the above-mentioned image to be tested based on the grayscale values ​​of the pixels in the above-mentioned target pixel set includes: integrating the grayscale values ​​of the pixels in the above-mentioned target pixel set to obtain the integral value of the pixel; and determining the grayscale characteristic value of the above-mentioned image to be tested based on the above-mentioned integral value of the pixel.

[0027] In a second aspect, the present application provides an image-based scene detection device, which includes: a feature extraction module, a pixel screening module, a feature value determination module and a feature value comparison module; wherein the feature extraction module is used to perform feature extraction on the image to be tested to obtain the grayscale distribution information of the pixels in the image to be tested; the pixel screening module is used to determine the pixels whose grayscale values ​​meet preset conditions based on the grayscale distribution information to obtain a target pixel set; the feature value determination module is used to determine the grayscale feature value of the image to be tested based on the grayscale values ​​of the pixels in the target pixel set; and the feature value comparison module is used to compare the grayscale feature value corresponding to the image to be tested with the scene recognition threshold to obtain the scene detection result of the image to be tested; wherein the scene recognition threshold is determined based on the grayscale feature value corresponding to the image under different scenes.

[0028] In an exemplary embodiment, based on the above scheme, the image-based scene detection device further includes: a threshold calculation module; wherein the threshold calculation module includes: an acquisition unit, a calculation unit, and a determination unit;

[0029] The acquisition unit is used to acquire sample images under N scenes, where N is an integer greater than 1; the calculation unit is used to calculate the i-th grayscale eigenvalue corresponding to the i-th scene based on the sample images under the i-th scene, where i is a positive integer less than N; and the determination unit is used to determine the i-th scene recognition threshold based on the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue; wherein the i-th scene recognition threshold is used to compare with the grayscale eigenvalue corresponding to the image to be tested, so as to determine whether the image to be tested belongs to the i+1-th scene or the i-th scene.

[0030] In an exemplary embodiment, based on the above scheme, the above i-th scene includes M sub-scenes; the sample image under the above i-th scene includes M sub-sample images corresponding to the M sub-scenes, where M is an integer greater than 1;

[0031] The above-mentioned calculation unit includes a first calculation subunit and a second calculation subunit; wherein the above-mentioned first calculation subunit is used to: calculate the sub-grayscale eigenvalues ​​corresponding to the sub-sample images under the above-mentioned i-th scene respectively, and obtain M sub-grayscale eigenvalues; and the above-mentioned second calculation subunit is used to: determine the grayscale eigenvalue corresponding to the above-mentioned i-th scene according to the above-mentioned M sub-grayscale eigenvalues; wherein the above-mentioned second calculation subunit is specifically used to: determine the j-th weight corresponding to the M sub-scenes under the above-mentioned i-th scene respectively, wherein j is a positive integer not greater than M; perform weighted processing on the sub-grayscale eigenvalue corresponding to the j-th sub-scene by the above-mentioned j-th weight; and determine the grayscale eigenvalue corresponding to the above-mentioned i-th scene according to the sub-grayscale eigenvalue after weighted processing.

[0032] In an exemplary embodiment, based on the above scheme, the above determination unit is specifically used to: determine the i-th interval, wherein the upper limit value of the i-th interval is the grayscale feature value corresponding to the i+1-th scene, and the lower limit value of the i-th interval is the grayscale feature value corresponding to the i-th scene; and determine the i-th scene recognition threshold according to the i-th interval, wherein the i-th scene recognition threshold belongs to the i-th interval.

[0033] In an exemplary embodiment, based on the above scheme, after the above determination unit determines the i-th scene recognition threshold according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue, the above threshold calculation module also includes: a scene switching threshold calculation unit; wherein the above scene switching threshold calculation unit is used to: determine the i-th scene switching high threshold corresponding to the situation where the i-th scene switches to the i+1-th scene; and, determine the i-th scene switching low threshold corresponding to the situation where the i+1-th scene switches to the i-th scene; wherein the i-th scene switching high threshold is greater than the i-th scene switching low threshold, and the i-th scene recognition threshold is greater than the i-th scene switching high threshold.

[0034] In an exemplary embodiment, based on the above scheme, the scene switching threshold calculation unit is specifically used to: obtain a plurality of first sample images corresponding to the case where the i-th scene is switched to the i+1-th scene; obtain first sample grayscale feature values ​​corresponding to the first sample images; and determine the i-th scene switching high threshold according to the statistical value of the first sample grayscale feature values;

[0035] The scene switching threshold calculation unit is also specifically used to: obtain multiple second sample images corresponding to the situation where the i+1th scene switches to the i-th scene; obtain second sample grayscale feature values ​​corresponding to the second sample images; and determine the i-th scene switching low threshold value based on the statistical value of the second sample grayscale feature values; wherein the difference between the i-th scene switching high threshold value and the i-th scene switching low threshold value is greater than a preset value.

[0036] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes; the sample images in the indoor scenes belong to a first image set consisting of sub-sample images corresponding to P indoor sub-scenes, and the sample images in the outdoor scenes belong to a second image set consisting of sub-sample images corresponding to Q outdoor sub-scenes, where P and Q are positive integers;

[0037] The calculation unit is specifically used to: calculate P sub-grayscale feature values ​​corresponding to the P sub-sample images in the first image set, and determine the grayscale feature value corresponding to the indoor scene according to the P sub-grayscale feature values;

[0038] The above-mentioned determination unit is specifically used to: determine a first interval, wherein the upper limit value of the above-mentioned first interval corresponds to the grayscale eigenvalue of the outdoor scene, and the lower limit value of the above-mentioned first interval corresponds to the grayscale eigenvalue of the indoor scene; and determine the indoor and outdoor scene recognition threshold according to the above-mentioned first interval, wherein the above-mentioned indoor and outdoor scene recognition threshold belongs to the above-mentioned first interval.

[0039] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes; the threshold calculation module also includes a switching threshold calculation unit; after the determination unit determines the i-th scene recognition threshold according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue, the switching threshold calculation unit is used to: determine the first scene switching threshold corresponding to the situation where the indoor scene switches to the outdoor scene; and, determine the second scene switching threshold corresponding to the situation where the outdoor scene switches to the indoor scene; wherein the first scene switching threshold is greater than the second scene switching low threshold, and the indoor and outdoor scene recognition threshold is greater than the first scene switching high threshold.

[0040] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes, and the i-th scene recognition threshold is an indoor and outdoor scene recognition threshold;

[0041] The above-mentioned comparison module is specifically used to: compare the grayscale feature value of the above-mentioned image to be tested with the above-mentioned indoor and outdoor scene recognition threshold; if the grayscale feature value of the above-mentioned image to be tested is greater than the above-mentioned indoor and outdoor scene recognition threshold, the scene detection result is that the above-mentioned image to be tested belongs to the outdoor scene; if the grayscale feature value of the above-mentioned image to be tested is less than or equal to the above-mentioned indoor and outdoor scene recognition threshold, the scene detection result is that the above-mentioned image to be tested belongs to the indoor scene.

[0042] In an exemplary embodiment, based on the above scheme, the above image-based scene detection device further includes: an identification object determination module and an association module;

[0043] The recognition object determination module is used to: determine the recognition object corresponding to the recognition occasion according to the recognition occasion before the acquisition unit acquires the sample images under N scenes;

[0044] The acquisition unit is specifically used to: acquire sample images of the same type of identification object in N scenes respectively;

[0045] The association module is used to: after determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value, determine a first association relationship between the i-th scene recognition threshold and the corresponding recognition occasion;

[0046] The above-mentioned image-based scene detection device further includes: an identification occasion determination module;

[0047] The recognition occasion determination module is used to determine the current recognition occasion before the comparison module compares the grayscale feature value of the image to be tested with the scene recognition threshold;

[0048] The association module is used to obtain, according to the current recognition scenario, a scene recognition threshold value having a first association relationship with the current recognition scenario, so as to compare the scene recognition threshold value with the grayscale characteristic value of the image to be tested.

[0049] In an exemplary embodiment, based on the above scheme, there is a second association relationship between the target recognition occasion and the target recognition object, wherein the scene recognition threshold having the first association relationship with the above target recognition occasion is determined with respect to a sample image of the above target recognition object;

[0050] The above-mentioned image-based scene detection device further includes: an identification occasion determination module and an identification object determination module;

[0051] The recognition occasion determination module is used to: determine the current recognition occasion before the feature extraction module extracts features from the image to be tested; and determine the current recognition object having a second association relationship with the current recognition occasion according to the current recognition occasion;

[0052] The above-mentioned identification object determination module is used to: determine whether the above-mentioned image to be tested contains the above-mentioned current identification object; wherein, when the above-mentioned image to be tested contains the above-mentioned current identification object, the step of extracting features from the image to be tested is performed; the above-mentioned image-based scene detection device also includes: an image acquisition module; the above-mentioned image acquisition module is used to: when the above-mentioned image to be tested does not contain the above-mentioned current identification object, re-acquire the image to be tested; wherein the above-mentioned image to be tested and the sample image used to determine the above-mentioned scene recognition threshold are both infrared images.

[0053] In an exemplary embodiment, based on the above scheme, the above pixel screening module is specifically used to: determine the total range of pixel grayscales in the above image to be tested according to the above grayscale distribution information; and determine a target range from the above total range, wherein the grayscale values ​​of pixels in the above target range meet a preset condition, wherein the grayscale value of the pixel under the preset condition is greater than the grayscale value of other pixels in the above total range except the above target range, or the grayscale value of the pixel under the preset condition is less than the grayscale value of other pixels in the above total range except the above target range;

[0054] The above-mentioned characteristic value determination module is specifically used to: integrate the grayscale values ​​of the pixels in the above-mentioned target pixel set to obtain the integral value of the pixel; and determine the grayscale characteristic value of the above-mentioned image to be tested according to the above-mentioned integral value of the pixel.

[0055] In a third aspect, an electronic device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method in the first aspect or its implementations.

[0056] In a fourth aspect, a chip is provided for implementing the method in any aspect or its implementation in the first aspect. Specifically, the chip includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes the method in the first aspect or its implementation in the first aspect.

[0057] In a fifth aspect, a computer-readable storage medium is provided for storing a computer program, wherein the computer program enables a computer to execute the method in the above-mentioned first aspect or its various implementations.

[0058] In a sixth aspect, a computer program product is provided, comprising computer program instructions, wherein the computer program instructions enable a computer to execute the method in the first aspect or each implementation manner.

[0059] In a seventh aspect, a computer program is provided, which, when executed on a computer, enables the computer to execute the method in the first aspect or its various implementations.

[0060] In summary, in the image-based scene detection scheme provided by the embodiment of the present application, feature extraction is performed on the image to be tested to obtain grayscale distribution information in the image to be tested. According to the grayscale distribution information, the pixels whose grayscale values ​​meet the preset conditions can be determined to obtain the target pixel set. Further, the grayscale values ​​of the pixels in the target pixel set are integrated to obtain the grayscale feature values ​​corresponding to the image to be tested. The embodiment of the present application determines the scene detection result of the image to be tested by comparing the grayscale feature values ​​of the image to be tested with the scene recognition threshold. Since the scene recognition threshold is also determined according to the grayscale feature values ​​corresponding to the sample image, the above comparison process is scientific and reasonable; at the same time, the above scene recognition threshold is determined according to the grayscale feature values ​​corresponding to the sample images in multiple different scenes, so the above comparison process can ensure accuracy. It can be seen that the scene detection scheme provided by the embodiment of the present application is simple and easy to operate and has a low investment cost while ensuring the detection accuracy, thereby reducing the application threshold of the scene detection scheme and facilitating the rapid promotion and popularization of the scene detection scheme. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of 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.

[0062] Figure 1 A schematic diagram of the system architecture of an image-based scene detection method provided in one embodiment of the present application;

[0063] Figure 2 A schematic diagram of an application scenario of an image-based scene detection method provided in an embodiment of the present application;

[0064] Figure 3 A schematic diagram of a flow chart of an image-based scene detection method provided in an embodiment of the present application;

[0065] Figure 4 A schematic diagram of a grayscale histogram provided in an embodiment of the present application;

[0066] Figure 5 A schematic diagram of a flow chart of a method for determining a scene recognition threshold provided in an embodiment of the present application;

[0067] Fig. 6A and Figure 6BA schematic diagram of sample images of the same identification object provided in an embodiment of the present application;

[0068] Fig. 7A An embodiment of the present application provides Fig. 6A Grayscale histogram of the indoor scene sample image shown;

[0069] Figure 7B An embodiment of the present application provides Figure 6B Grayscale histogram of the sample image of the outdoor scene shown;

[0070] Figure 8 A schematic diagram of a flow chart of an image-based scene detection method provided for an exemplary embodiment of the present application;

[0071] Fig. 9 A schematic diagram of the structure of an image-based scene detection device provided in one embodiment of the present application;

[0072] Fig.10 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0073] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0074] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here can be implemented in a sequence other than those illustrated or described here. In the present application embodiment of the present invention, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined according to A. However, it should also be understood that determining B according to A does not mean determining B only according to A, but can also determine B according to A and / or other information. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. In the description of the present application, unless otherwise specified, "multiple" refers to two or more than two.

[0075] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0076] Scene detection plays a vital role in the process of computer systems understanding and parsing image content. Specifically, it can help computer systems understand the objects in the image and their environment more deeply and accurately, and implement adaptive exposure strategies in different indoor and outdoor scenes, so as to obtain clear and high-quality indoor and outdoor images, and further improve the accuracy of image recognition and analysis. It has broad application potential in many fields of life. Exemplarily, the scene detection technology solution proposed in this application can be applied to technical fields such as biological liveness detection and unmanned driving, and is used to determine the current scene type, for example, whether it belongs to an indoor scene or an outdoor scene, so that an adaptive exposure strategy can be implemented in different indoor and outdoor scenes, which is conducive to obtaining clear and high-quality indoor and outdoor images, and ultimately helps to improve the accuracy of biological liveness detection, the reliability of unmanned driving, and the accuracy of safety detection.

[0077] The indoor and outdoor scene recognition and detection solutions provided by related technologies are as follows:

[0078] The first indoor and outdoor scene recognition detection solution is to detect indoor and outdoor scenes based on the historical results of mobile terminals and satellite positioning information. This related technology can ensure the detection accuracy of indoor and outdoor scenes, but its initial deployment and investment costs are high, so its popularity in practical applications is limited.

[0079] The second indoor and outdoor scene recognition detection solution is to use the sensors integrated in the smart terminal to collect data, select the best feature subset as the classification attribute to train the classifier, and thus determine the indoor and outdoor scenes. However, this method requires a lot of time and effort in the early preparation stage, and requires the storage of a large amount of data to achieve rapid judgment, so its application in indoor and outdoor scene detection is relatively limited.

[0080] The third indoor and outdoor scene recognition detection solution is to collect information such as light intensity, temperature and humidity, and geomagnetism through sensors, calculate the corresponding indoor confidence, and thus determine whether the environment is indoors or outdoors. However, this method has a high computational complexity and is difficult to be widely used in large-scale scenarios.

[0081] The embodiments of the present application can solve the above-mentioned technical problems existing in the related art. Specifically, in the image-based scene detection scheme provided by the embodiments of the present application, feature extraction is performed on the image to be tested to obtain grayscale distribution information in the image to be tested. According to the above grayscale distribution information, pixels whose grayscale values ​​meet preset conditions can be determined to obtain a target pixel set. Furthermore, the grayscale values ​​of the pixels in the target pixel set are integrated and calculated to obtain the grayscale characteristic values ​​corresponding to the image to be tested. The embodiments of the present application determine the scene detection result of the image to be tested by comparing the grayscale characteristic values ​​of the image to be tested with the scene recognition threshold. Since the scene recognition threshold is also determined based on the grayscale characteristic values ​​corresponding to the sample image, the above comparison process is scientific and reasonable; at the same time, the above scene recognition threshold is determined based on the grayscale characteristic values ​​corresponding to the sample images in multiple different scenes, so the above comparison process can ensure accuracy. It can be seen that the scene detection solution provided in the embodiment of the present application breaks through the limitations of traditional methods and lowers the technical threshold. While ensuring the accuracy of detection, the operation process is simple and easy, which is conducive to rapid popularization and promotion in various application scenarios, so that more fields and scenarios can benefit from indoor and outdoor scene detection technology.

[0082] Below through Figure 1 An exemplary system architecture of an embodiment of the present application is introduced.

[0083] Figure 1 A schematic diagram of the system architecture of an image-based scene detection method provided in an embodiment of the present application. Figure 1 , an image-based scene recognition system construction 100 may include an image acquisition device 102 and a computing device 104 .

[0084] Among them, the above-mentioned image acquisition device 102 is used to acquire the image to be tested. Exemplarily, the content acquired by the image acquisition device 102 can be a single image or a frame of an image in a captured video, which is not limited in the embodiment of the present application. In an exemplary embodiment, since infrared imaging can work under various lighting conditions and is not restricted by various scenes, including dark and strong light environments, the above-mentioned acquisition device can be an end point device with infrared imaging function. At the same time, the embodiment of the present application does not limit the specific type of the image acquisition device 102. For example, in some embodiments, the image acquisition device 102 may include but is not limited to: infrared camera, infrared camera, mobile phone, computer, vehicle terminal, aircraft, intelligent voice interaction device, smart home appliance, wearable smart device, medical device, etc. In addition, the image acquisition device 102 can be configured with a display device, which can also be a display, a display screen, a touch screen, etc., and the touch screen can also be a touch screen, a touch panel, etc.; of course, the image acquisition device 102 can also not be configured with a display device itself, but transmit the acquired image to other terminals by wired or wireless means for users to view or operate; the embodiment of the present application does not limit this.

[0085] The computing device 104 is used to perform feature extraction on the image to be tested to obtain the grayscale distribution information of the pixels in the image to be tested. The computing device 104 also determines the pixels whose grayscale values ​​meet the preset conditions based on the grayscale distribution information to obtain the target pixel set. Furthermore, the computing device 104 integrates the grayscale values ​​of the pixels in the target pixel set to obtain the grayscale characteristic value. And, the computing device 104 compares the grayscale characteristic value corresponding to the image to be tested with the scene recognition threshold to obtain the scene detection result of the image to be tested; wherein, the scene recognition threshold is determined according to the grayscale characteristic value corresponding to the image in different scenes. Exemplarily, the computing device 104 can also be used to calculate the above-mentioned scene recognition threshold; of course, the above-mentioned scene recognition threshold can also be calculated by other devices and then passed to the computing device 104, and the embodiment of the present application does not limit this.

[0086] In some embodiments, the computing device 104 may be a server. The server may be one or more. When there are multiple servers, there are at least two servers for providing different services, and / or there are at least two servers for providing the same service, such as providing the same service in a load balancing manner, which is not limited in the embodiments of the present application. Among them, the above-mentioned server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0087] It should be noted that the system architecture of the embodiment of the present application includes but is not limited to Figure 1 For example, in Figure 1 In the illustrated system architecture 100, after the image acquisition device 102 acquires the image to be tested, the image to be tested is transmitted to the computing device 104, so that the computing device 104 performs the above-mentioned calculation process. In other exemplary equivalent architectures, the above-mentioned calculation process may also be integrated inside the image acquisition device 102, that is, after the image acquisition device 102 acquires the image to be tested, the above-mentioned calculation process may be performed through its own calculation function to determine the scene type to which the above-mentioned image to be tested belongs. This embodiment of the present application does not limit this.

[0088] Below through Figure 2 Exemplary application scenarios of the embodiments of the present application are introduced.

[0089] Figure 2 A schematic diagram of an application scenario of an image-based scene detection method provided in an embodiment of the present application. Figure 2In the access control usage scenario, the image acquisition device 102 can be used to collect the user's biometric features, such as facial features. In other embodiments, it can also be fingerprint features, iris features, etc. Further, in the access control related algorithm, the collected image information will be compared with the authenticated user information to determine whether the current user 20 is a registered user, thereby achieving the effect of releasing the registered user and prohibiting the entry of unregistered users. In this usage scenario, the solution provided by the embodiment of the present application can determine the scene in which the image currently collected by the image acquisition device 102 is located. In other words, the solution provided by the embodiment of the present application can be used to determine the scene in which the current user 20 is located, such as an indoor scene or an outdoor scene. Furthermore, the computing device can adaptively adjust the exposure strategy according to the scene type of the image to be tested, which is conducive to obtaining clear and high-quality indoor and outdoor images, and then it is conducive to improving the accuracy of biological liveness detection and improving the reliability of the access control system.

[0090] It should be noted that the application scenarios of the embodiments of the present application include but are not limited to Figure 2 shown.

[0091] The technical solutions of the embodiments of the present application are described in detail below through some embodiments. The following embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0092] Figure 3 This is a flow chart of an image-based scene detection method P300 provided in one embodiment of the present application. Figure 3 , method P300 includes steps S310-S340.

[0093] In step S310, feature extraction is performed on the image to be tested to obtain grayscale distribution information of pixels in the image to be tested.

[0094] Among them, the grayscale distribution information of the above-mentioned image pixels refers to the result obtained after statistical analysis of all pixels in the image according to their grayscale values. Grayscale distribution information can reflect the distribution of image brightness levels. In an embodiment of the present application, the scene type to which the image to be tested belongs is determined based on the similarity between the grayscale distributions of images in the same or similar scenes, or the difference in the grayscale distribution laws of images between different scenes. Among them, the amount of calculation required to obtain the grayscale distribution information of the image to be tested is relatively small, so near real-time scene detection can be achieved, and the small amount of calculation saves a lot of investment costs.

[0095] In an exemplary embodiment, the grayscale histogram is a function of grayscale distribution, which is used to count the grayscale distribution in an image. The grayscale histogram counts the frequency of occurrence of all pixels in an image according to the size of the grayscale value. The grayscale histogram is a function of grayscale, which indicates the number of pixels with a certain grayscale in an image, and can reflect the frequency of occurrence of a certain grayscale value in the image. Therefore, in the embodiment of the present application, the grayscale distribution information of the image can be obtained by obtaining the grayscale histogram of the image to be tested.

[0096] In an exemplary embodiment, the specific implementation of obtaining the grayscale histogram of the image to be tested may include:

[0097] Step S1, use an image reading function (eg, cv2.imread function) to read an image.

[0098] For example, when the image to be measured is a visible light image, the grayscale image corresponding to the grayscale image can be obtained by the above image reading function in grayscale. For example, infrared imaging can work under various lighting conditions, without being restricted by various scenes, including dark and strong light environments. Therefore, it can also work under conditions of large changes in light intensity or insufficient light.

[0099] In a grayscale image, the grayscale value of each pixel is usually between 0 and the maximum grayscale value (for example, in an 8-bit grayscale image, the maximum grayscale value is 255). Figure 4 In the grayscale histogram, the horizontal axis represents the grayscale value, and the vertical axis represents the number of pixels with this grayscale value.

[0100] Step S2: For the grayscale image corresponding to the image to be tested, a function for calculating the histogram of a one-dimensional array (eg, the np.histogram function of NumPy) is used to calculate the grayscale histogram of the image.

[0101] Exemplarily, when the image determined in step S1 is an 8-bit grayscale image, the grayscale level may be divided into 256 buckets (from 0 to 255).

[0102] Step S3: Display the histogram by using a display function (e.g., cv2.imshow function). Figure 4 shown.

[0103] refer to Figure 4 In the grayscale histogram shown in FIG, the largest number of pixels is distributed between grayscale values ​​25 and 50. The grayscale histogram can intuitively reflect the grayscale distribution characteristics of the image to be tested, which is conducive to determining the scene to which the image to be tested belongs based on the grayscale distribution characteristics.

[0104] Continue to refer Figure 3The method P300 further includes step S320: determining pixels whose grayscale values ​​meet preset conditions according to the grayscale distribution information to obtain a target pixel set.

[0105] As mentioned above, there is similarity between the grayscale distributions of images in the same or similar scenes. In order to improve the accuracy and reliability of scene detection, the embodiments of the present application will first determine the pixel set that best represents the scene in which the image is located based on the grayscale distribution information, and then calculate the grayscale feature values ​​of the pixels in the determined pixel set; further, the above-mentioned grayscale feature values ​​of the image to be tested are compared with a predetermined scene recognition threshold.

[0106] In an exemplary embodiment, in the embodiment of the present application, the pixel that best represents the scene in which the image is located is the pixel that meets the preset condition. Exemplarily, the above preset condition can be a pixel with a relatively large grayscale value in the entire image, or a pixel with a relatively small grayscale value in the entire image. It should be noted that the preset condition used to determine the target pixel set in the image to be tested is the same as the preset condition used in the process of determining the scene recognition threshold, thereby ensuring the accuracy and reliability of scene detection.

[0107] As a specific implementation of step S320, the following steps may be performed.

[0108] In step S320-1, the total range of pixel grayscales in the image to be tested is determined according to the grayscale distribution information of the image to be tested. Figure 4 After determining the grayscale histogram corresponding to the above-mentioned image to be tested, it can be determined that the total range of the pixel grayscale in the image to be tested is 30-220.

[0109] In step S320-2, a target range is determined from the total range of the above-mentioned pixel grayscales, wherein the grayscale values ​​of the pixels within the target range meet a preset condition, wherein the preset condition pixel grayscale value is greater than the grayscale values ​​of other pixels in the total range except the target range, or the preset condition pixel grayscale value is less than the grayscale values ​​of other pixels in the total range except the target range. Exemplarily, the m% of the maximum grayscale values ​​in the total range are taken as the target range. If m is 3, the pixels in the brightest 3% area of ​​the image to be tested are selected as the pixels in the target pixel set. For example, referring to Figure 4 , the total range of pixel grayscale in the image to be tested is 30–220, and the range of pixel grayscale in the brightest 3% area that meets the preset conditions is [(220-220×3%), 220]. It can be seen that in the embodiment of the present application, the grayscale range of the pixels in the target pixel set is [Grayscale max ×(1-m%), Grayscale max ], among which Grayscalemax Indicates the maximum grayscale value of pixels in the image.

[0110] Continue to refer Figure 3 The method P300 further includes step S330: determining the grayscale characteristic value of the image to be tested according to the grayscale value of the pixels in the target pixel set.

[0111] In the embodiment of the present application, after determining that the pixel that best represents the scene of the image is the pixel that meets the preset condition, the statistical value of the grayscale of the pixels in the pixel set can be used as the grayscale feature value of the image. Exemplarily, as a specific implementation of step S330, the following steps are performed.

[0112] In step S330 - 1 , the grayscale values ​​of the pixels in the target pixel set are integrated to obtain an integral value of the pixel.

[0113] As mentioned above, the grayscale range of the pixels in the target pixel set is [Grayscale max ×(1-m%), Grayscale max ], perform integral calculation on the grayscale values ​​of the pixels within the range of the image. The integral calculation here is not the integral in the traditional mathematical sense, but refers to the cumulative sum of all grayscale values ​​within the grayscale interval. Specifically, the grayscale value of each pixel within the grayscale range is multiplied by its number in the image, and then added; for example, the grayscale values ​​included in the above grayscale range are a, b and c, where the number of pixels with grayscale value a is x1, the number of pixels with grayscale value b is x2, and the number of pixels with grayscale value c is x3, then the integral value Z of the pixels within the range can be expressed as: Z = a×x1+b×x2+c×x3.

[0114] In step S330 - 2 , the grayscale characteristic value of the image to be tested is determined according to the above-mentioned integral value of the pixel.

[0115] Exemplarily, the integral value Z of the pixels in the above target pixel set can be directly used as the grayscale characteristic value of the image. Exemplarily, after calculating the integral value Z of the pixels in the above target pixel set, the mean grayscale value can be calculated as the grayscale characteristic value of the image to be tested; for example, the grayscale values ​​included in the above grayscale range are a, b and c, where the number of pixels with grayscale value a is x1, the number of pixels with grayscale value b is x2, and the number of pixels with grayscale value c is x3, then the integral value Z of the pixels in the range can be expressed as: Z = a×x1+b×x2+c×x3; then the grayscale characteristic value of the image to be tested can be expressed as Z / (a+b+c).

[0116] It is understandable that in order to ensure the accuracy and reliability of scene detection in the embodiment of the present application, the method for determining the grayscale feature value of the above-mentioned image to be tested is consistent with the method for determining the grayscale feature value in the process of calculating the scene recognition threshold.

[0117] Continue to refer Figure 3 Method P300 also includes step S340: comparing the grayscale feature value corresponding to the image to be tested with the scene recognition threshold to obtain the scene detection result of the image to be tested; wherein the scene recognition threshold is determined according to the grayscale feature value corresponding to the image under different scenes.

[0118] In this exemplary embodiment, the grayscale feature value of the above-mentioned image to be tested is compared with the pre-acquired scene recognition threshold to determine the scene to which the image to be tested belongs. Among them, since the scene recognition threshold is also determined according to the grayscale feature value corresponding to the sample image, the above-mentioned comparison process is reasonable; the above-mentioned scene recognition threshold is determined according to the grayscale feature value corresponding to the sample image under multiple different scenes, so the above-mentioned comparison process can ensure accuracy; at the same time, the embodiment of the present application determines the scene to which the image to be tested belongs by comparing the grayscale feature values, and the amount of calculation is small. It can be seen that the scene detection scheme provided in the embodiment of the present application is simple and easy to operate while ensuring the detection accuracy, which is conducive to the rapid popularization and promotion of the scheme provided in the embodiment of the present application in various application scenarios.

[0119] Figure 5 This is a flow chart of a method P500 for determining a scene recognition threshold according to an embodiment of the present application. Figure 5 , method P500 includes steps S510 to S530.

[0120] In step S510, sample images under N scenes are obtained, where N is an integer greater than 1.

[0121] Among them, the N scenes can be multiple scenes with different lighting conditions, that is, it can be understood that the lighting conditions in the i-th scene are different from the lighting conditions in the i+1-th scene. It is understandable that the above N scenes can also be multiple scenes with different temperature conditions, such as the temperature in the first scene is generally below 0 degrees Celsius, the temperature in the second scene is generally between 0 degrees Celsius and 20 degrees Celsius, and so on. It is understandable that the above N scenes can also be multiple scenes with different other conditions, and the embodiments of the present application do not limit this.

[0122] In an exemplary embodiment, for the same scene, at least one sample image is acquired. Further, a threshold for distinguishing different scenes is determined based on the grayscale feature values ​​of the images corresponding to different scenes, which is recorded as a scene recognition threshold.

[0123] In an exemplary embodiment, the objects to be identified in different identification scenarios are different, for example, in face recognition scenarios, the object to be identified is a face, in iris recognition scenarios, the object to be identified is an eye, in fingerprint recognition scenarios, the object to be identified is a palm, etc. Therefore, the sample images used to determine the scene recognition threshold in the target recognition scenario are images of the same target recognition object, so as to ensure that the determined threshold fits the actual use scenario and ensure the reliability of scene detection in different recognition scenarios. For example, Fig. 6A and Figure 6B An image of the same identification object in an embodiment of the present application is shown, wherein Fig. 6A These are sample images of palms in indoor scenes. Figure 6B For sample images of palms in outdoor scenes, Fig. 6A and Figure 6B The sample image shown can be used to calculate an indoor and outdoor recognition threshold X, and the indoor and outdoor recognition threshold X is suitable for fingerprint recognition scenarios.

[0124] In step S520, the i-th grayscale feature value corresponding to the i-th scene is calculated according to the sample image under the i-th scene, where i is a positive integer less than N.

[0125] In an exemplary embodiment, as a specific implementation of step S520, steps S520-1 to S520-3 may be performed. In step S520-1, feature extraction is performed on the sample image in the i-th scene to obtain grayscale distribution information of pixels in the sample image. The sample image in the i-th scene may be one or more, and the specific implementation of calculating the grayscale distribution information corresponding to each sample image is the same as the specific implementation of S310, which will not be repeated here. For example, Fig. 6A The grayscale distribution information of the sample image in the indoor scene is shown as Fig. 7A The grayscale histogram shown is Figure 6B The grayscale distribution information of the sample image in the outdoor scene is shown as Figure 7B In step S520-2, based on the grayscale distribution information of the sample image in the i-th scene, the pixels whose grayscale values ​​meet the preset conditions are determined to obtain the target pixel set. Wherein, when the number of sample images in the i-th scene is one, the specific implementation of this step is the same as that of S320, and will not be repeated here. For example, Fig. 7A In the grayscale histogram shown in FIG. 7 , the pixels in the target range 71 are Fig. 6A The 3% pixels with the largest grayscale values ​​in the sample image; Figure 7B In the grayscale histogram shown in FIG. 7 , the pixels of the target range 72 are Figure 6BThe 3% pixels with the largest grayscale values ​​in the sample image. In step S520-3, the grayscale characteristic value of the sample image in the i-th scene is determined according to the grayscale value of the pixels in the above-mentioned target pixel set. The specific implementation of this step is the same as the specific implementation of S330 and will not be repeated here; when the number of sample images in the i-th scene is one, the grayscale characteristic value of the single sample can be used as the grayscale characteristic value corresponding to the scene; when the number of sample images in the i-th scene is multiple, the average of the grayscale characteristic values ​​of the multiple samples can be used as the grayscale characteristic value corresponding to the scene.

[0126] refer to Fig. 7A and Figure 7B It can be seen from the grayscale histogram of the sample image in the indoor scene and the grayscale histogram in the outdoor scene that there are obvious differences between the grayscale distributions of the images in different scenes. Therefore, the scene recognition threshold determined based on the grayscale feature values ​​of the sample images in different scenes can effectively distinguish the scene to which the image to be tested belongs. Therefore, the scene detection scheme provided in the embodiment of the present application has high accuracy and reliability.

[0127] In an exemplary embodiment, in order to improve the reliability of the grayscale feature value corresponding to the i-th scene, multiple sub-scenes under the i-th scene can be obtained, and the grayscale feature value under the scene can be determined according to the sub-grayscale feature values ​​corresponding to each sub-scene, wherein the multiple sub-scenes can ensure the comprehensiveness of different image features under the i-th scene, and then the grayscale feature value determined according to the sub-grayscale features of the multiple sub-scenes has higher reliability.

[0128] Exemplarily, the i-th scene includes M sub-scenes, and the sample image under the i-th scene includes M sub-sample images corresponding to the M sub-scenes. When the number of sample images under the i-th scene is a plurality of images corresponding to the M sub-scenes, the specific implementation of step S520 may include: step S520-1' and step S520-2'.

[0129] In step S520 - 1 ′, the sub-grayscale feature values ​​corresponding to the sub-sample images in the i-th scene are calculated to obtain M sub-grayscale feature values.

[0130] The specific implementation of calculating the sub-grayscale feature value corresponding to each sub-sample image is the same as the specific implementation of step S310 to step S330, and will not be repeated here.

[0131] In step S520-2', the grayscale characteristic value corresponding to the i-th scene is determined according to the M sub-grayscale characteristic values.

[0132] Exemplarily, determine the jth weight corresponding to each of the M sub-scenes in the i-th scene, where j is a positive integer not greater than M; perform weighted processing on the sub-grayscale eigenvalue corresponding to the j-th sub-scene by the jth weight; and determine the grayscale eigenvalue corresponding to the i-th scene according to the weighted sub-grayscale eigenvalue. For example, the i-th scene is an indoor scene, which includes two sub-scenes, namely, a scene without additional lighting during the day and a scene with additional lighting during the day, and the weights corresponding to the two sub-scenes are 0.3 and 0.7, respectively. Then, the grayscale eigenvalue corresponding to the indoor scene is: the sum of the sub-grayscale eigenvalue corresponding to the scene without additional lighting during the day multiplied by 0.3 and the sub-grayscale eigenvalue corresponding to the scene with additional lighting during the day multiplied by 0.7. In the embodiment of the present application, the method of setting weights for each sub-scene makes the grayscale eigenvalue corresponding to the scene more flexible, and the user can adjust the weights corresponding to different sub-scenes according to actual conditions, thereby improving the applicability of the scene detection solution.

[0133] For example, taking the determination of a scene recognition threshold for distinguishing indoor scenes from outdoor scenes (denoted as indoor and outdoor scene recognition threshold) as an example, the specific implementation of step S520 - 1 ′ and step S520 - 2 ′ is introduced.

[0134] Assume that the sample images under the indoor scene belong to the first image set and the first image set is composed of P sub-sample images corresponding to the indoor sub-scenes, and the sample images under the outdoor scene belong to the second image set and the second image set is composed of Q sub-sample images corresponding to the outdoor sub-scenes, where P and Q are positive integers. First, calculate the P sub-grayscale eigenvalues ​​corresponding to the P sub-sample images in the first image set, and then determine the grayscale eigenvalues ​​corresponding to the indoor scene according to the P sub-grayscale eigenvalues. For example, the P sub-sample images in the first image set are sub-sample image A1 in a pure dark room and sub-sample image B1 in a pure dark room with fill light. Among them, the weight corresponding to sub-sample image A1 is 0.2 and the weight corresponding to sub-sample image B1 is 0.8, and the grayscale eigenvalue corresponding to sub-sample image A1 is a1 and the grayscale eigenvalue corresponding to sub-sample image B1 is b1, then the grayscale eigenvalue corresponding to the indoor scene is X1=0.2×a1+0.8×b1.

[0135] Similarly, the Q sub-sample images in the second image set are sub-sample image A2 in cloudy outdoor conditions and sub-sample image B2 in positive side light outdoor conditions. Among them, the weight corresponding to sub-sample image A2 is 0.4 and the weight corresponding to sub-sample image B2 is 0.6, and the grayscale feature value corresponding to sub-sample image A2 is a2 and the grayscale feature value corresponding to sub-sample image B2 is b2, then the grayscale feature value corresponding to the outdoor scene is X2=0.4×a2+0.6×b2.

[0136] Next, continue to refer to Figure 5, method P500 also includes step S530: determining the i-th scene recognition threshold according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue; wherein the i-th scene recognition threshold is used to compare with the grayscale eigenvalue corresponding to the image to be tested to determine whether the image to be tested belongs to the i+1-th scene or the i-th scene.

[0137] As a specific implementation of S530, the following steps are performed:

[0138] In step S530-1, the i-th interval is determined, wherein the upper limit value of the i-th interval is the grayscale feature value corresponding to the i+1-th scene, and the lower limit value of the i-th interval is the grayscale feature value corresponding to the i-th scene; and in step S530-2, the i-th scene recognition threshold is determined according to the i-th interval, wherein the i-th scene recognition threshold belongs to the i-th interval.

[0139] Exemplarily, taking the determination of indoor and outdoor scene recognition thresholds as an example, since the grayscale feature value X1 can reflect the grayscale features of the image in the indoor scene, and the grayscale feature value X2 can reflect the grayscale features of the image in the outdoor scene, the value between X1 and X2 can be used as the scene recognition threshold to distinguish indoor scenes from outdoor scenes. Specifically, the grayscale feature value X2 corresponding to the outdoor scene is used as the upper limit of the interval, and the grayscale feature value X1 corresponding to the indoor scene is used as the lower limit of the interval, and the obtained interval is expressed as [X1, X2]. Further, the value within the interval is determined as the above-mentioned indoor and outdoor scene recognition threshold, for example, the middle value of the interval X = (X1 + X2) / 2 is used as the above-mentioned indoor and outdoor scene recognition threshold. As an implementation method of step S340, the grayscale eigenvalue Z / (a+b+c) of the image to be tested is compared with the above-mentioned indoor and outdoor scene recognition threshold X. If the grayscale eigenvalue Z / (a+b+c) of the image to be tested is greater than the indoor and outdoor scene recognition threshold X, the scene detection result is that the image to be tested belongs to an outdoor scene; if the grayscale eigenvalue Z / (a+b+c) of the image to be tested is less than or equal to the indoor and outdoor scene recognition threshold X, the scene detection result is that the image to be tested belongs to an indoor scene.

[0140] In the solution provided by method P500, the scene recognition threshold is determined according to the grayscale feature value of the image in different scenes, and the algorithm used to determine the scene recognition threshold can be flexibly adjusted according to actual needs, so that the dynamically adjusted scene device threshold can be determined, thereby ensuring that the user experience in indoor and outdoor scenes is optimized, which not only improves the real-time and accuracy of image processing, but also further enhances the stability and reliability of the system.

[0141] Figure 8The flowchart of the image-based scene detection method P800 provided for an exemplary embodiment of the present application is as follows. As mentioned above, for the same recognition occasion, the samples used to determine the scene recognition threshold are images of the same type of object, such as Fig. 6A and Figure 6B The sample images shown are all images of palms. Therefore, there is an association between the recognition occasion and the recognition object, and there is also an association between the recognition occasion and the scene recognition threshold. In the embodiment of the present application, the association between the recognition occasion and the recognition object is recorded as the second association, and the association between the recognition occasion and the scene recognition is recorded as the first association. For example, for a certain face recognition occasion, it can be determined that the recognition object in the current occasion is a face based on the second association, and the scene recognition threshold used in the face recognition occasion can be determined based on the first association. Reference Figure 8 , method P800 includes the following steps.

[0142] In step S810, the current recognition occasion is determined.

[0143] In step S820, according to the current recognition scenario, a current recognition object having a second association relationship with the current recognition scenario is determined.

[0144] In step S830, an image to be tested is acquired.

[0145] In step S840, it is determined whether the image to be tested contains the current identification object.

[0146] It can be seen that in the embodiment of the present application, before performing feature extraction on the image to be tested, it is first determined whether there is an identification object in the current image to be tested according to the identification scenario. For example, in the face recognition scenario, it is first determined whether there is a face in the image to be tested. In the case where it is determined that there is no identification object corresponding to the current identification scenario in the image to be tested, since the scene recognition threshold is calculated based on the sample image containing the identification object, the current image to be tested does not contain the identification object and is therefore not suitable for comparison with the scene recognition threshold. If it is compared with the scene recognition threshold, an inaccurate scene detection result may be obtained. Therefore, it is necessary to perform step S830 again to reacquire the image to be tested, and perform step S840 again to ensure that the image to be tested contains the identification object, and then perform feature extraction and other steps on the image to be tested containing the identification object to determine the grayscale feature value. Since the scene recognition threshold is calculated based on the sample image containing the identification object, the current image to be tested also contains the identification object, so the grayscale feature value of the current image to be tested is suitable for comparison with the scene recognition threshold, and then determine an accurate scene detection result.

[0147] Continue to refer Figure 8In step S850, according to the current recognition occasion, a scene recognition threshold having a first association relationship with the current recognition occasion is obtained. Thus, a quick and convenient method for determining the scene recognition threshold is provided. Among them, step S850 and steps S310-S330 can be executed in parallel.

[0148] Furthermore, in step S860, the grayscale feature value corresponding to the image to be tested is compared with the scene recognition threshold to obtain the scene detection result of the image to be tested. The specific implementation of this step is the same as the specific implementation of step S340, which will not be repeated here.

[0149] In the solution provided by method P800, the current identification object and the scene identification threshold in the current identification occasion can be accurately and quickly determined according to the pre-set association relationship. At the same time, before extracting features from the image to be tested, it is first determined whether the current identification object exists in the current image. In this way, the image to be tested can be guaranteed to be a qualified image. Since the qualified image and the sample image used to determine the scene identification threshold contain the same type of identification object, the rationality of comparing the grayscale feature value of the image to be tested with the scene identification threshold can be guaranteed, which is conducive to ensuring the reliability of the scene detection result.

[0150] In an exemplary embodiment, in order to further improve the accuracy of scene recognition, the embodiment of the present application sets the above N scenes (which can be called basic scenes) and further provides a finer scene segmentation granularity. Exemplarily, after determining the scene recognition threshold for distinguishing different scenes, it is also possible to determine the i-th scene switching high threshold corresponding to the case of switching from the i-th scene to the i+1-th scene, and the i-th scene switching low threshold corresponding to the case of switching from the i+1-th scene to the i-th scene.

[0151] When using infrared images, since the grayscale distribution in the infrared image is affected by factors such as the temperature and reflectivity of the identification object itself, the temperature or reflectivity of the identification object is different when it just experiences a scene switch and when it remains in the scene after the switch for a long time. Therefore, the grayscale distribution in the image captured after the identification object experiences a scene switch is different from the grayscale distribution in the image when the identification object remains in the scene after the switch for a long time.

[0152] Exemplarily, a large number of infrared images of the identified object within a preset time (e.g., 5 seconds) after the scene is switched are obtained, and the grayscale feature values ​​of these images are counted, and the statistical value is determined as the corresponding switching threshold. Specifically, the specific implementation method for determining the high threshold of the i-th scene switch includes: in S11, obtaining multiple first sample images corresponding to the situation of switching from the i-th scene to the i+1-th scene; in S12, taking the first sample grayscale feature value corresponding to the first sample image; in S13, determining the i-th scene switch high threshold according to the statistical value of the first sample grayscale feature value. For example, if the i-th scene is an indoor scene and the i+1-th scene is an outdoor scene, then the first sample image is the infrared image just switched from the indoor scene to the outdoor scene, and the average value of the grayscale feature values ​​of these infrared images is 80000, then it can be determined that the first scene switch threshold corresponding to the situation of switching from the indoor scene to the outdoor scene is 80000.

[0153] Similarly, the specific implementation method for determining the i-th scene switching low threshold includes: in S21, obtaining multiple second sample images corresponding to the situation of switching from the i+1th scene to the i-th scene; in S22, taking the second sample grayscale feature value corresponding to the second sample image; in S23, determining the i-th scene switching low threshold according to the statistical value of the second sample grayscale feature value. For example, if the i-th scene is an indoor scene and the i+1th scene is an outdoor scene, then the second sample image is an infrared image just switched from an outdoor scene to an indoor scene, and the average value of the grayscale feature values ​​of these infrared images is 70000, then it can be determined that the second scene switching threshold corresponding to the situation of switching from an outdoor scene to an indoor scene is 70000.

[0154] After determining the first scene switching threshold and the second scene switching threshold, if the difference between the grayscale feature value of the image to be tested and the scene switching threshold is small, such as within 500, it can be considered that the image to be tested belongs to the scene corresponding to the scene switching threshold.

[0155] In an exemplary embodiment, in a certain face recognition scenario, the grayscale eigenvalue corresponding to the indoor scene is calculated to be 35, and the grayscale eigenvalue corresponding to the outdoor scene is 146835, then the indoor and outdoor scene switching threshold can be set to 73400. In this case, the grayscale eigenvalue of the image to be tested can be compared with the scene switching threshold x. If x is less than 73400, the scene to which the image to be tested belongs is considered to be an indoor scene, and if x is greater than 73400, the scene to which the image to be tested belongs is considered to be an outdoor scene. Furthermore, in order to further improve the recognition accuracy, the first scene switching threshold is determined to be 80000 and the second scene switching threshold is 70000 by statistics. If the grayscale eigenvalue x of the image to be tested is 700450, since the difference between x and the second scene switching threshold 70000 is small, it can be determined that the scene to which the image to be tested belongs is a scene switched from outdoor to indoor.

[0156] In an exemplary embodiment, in order to increase the distinction between scenes and increase the reliability of scene detection, a larger difference is set between the i-th scene switching low threshold and the i-th scene switching high threshold in the embodiment of the present application, such as the difference is greater than the preset value of 10000.

[0157] In an exemplary embodiment, in order to meet the needs of more refined scene differentiation, in addition to setting the above-mentioned scene segmentation threshold, the scene can also be subdivided on the basis of N scenes. For example, after determining the scene recognition thresholds for indoor scenes and outdoor scenes, the sub-thresholds corresponding to the semi-indoor scenes and then the semi-outdoor scenes can also be obtained. Among them, the semi-indoor scene is, for example, an area close to the outdoors indoors, such as a window sill, a corridor close to the outdoors, etc., and the semi-outdoor scene can be, for example, a dense forest outdoors, an outdoor corridor, etc. Exemplarily, the above-mentioned sub-threshold can be determined by obtaining a large number of sample images of the identified object in the corresponding scene, and counting the grayscale feature values ​​of these images, and determining the statistical value as the corresponding sub-threshold. For example, the sub-threshold corresponding to the semi-indoor scene is determined by obtaining a large number of sample images of the identified object in the semi-indoor scene, and counting the grayscale feature values ​​of these images, and determining the statistical value as the sub-threshold corresponding to the semi-indoor scene. Similarly, the sub-threshold corresponding to the semi-outdoor scene is determined by obtaining a large number of sample images of the identified object in the semi-outdoor scene, and counting the grayscale feature values ​​of these images, and determining the statistical value as the sub-threshold corresponding to the semi-outdoor scene. After determining the above-mentioned half-indoor sub-threshold, if the difference between the grayscale feature value of the image to be tested and the half-indoor sub-threshold is small, if it is within 500, it can be considered that the image to be tested belongs to the half-indoor scene.

[0158] The image-based scene detection method provided in the embodiment of the present application utilizes the principle of infrared light imaging to accurately identify the differences in imaging characteristics between indoor and outdoor scenes. Specifically, in the scene detection process, key features are extracted from the image to be tested, and the pixel integral of the brightest area in the image to be tested is analyzed, and the grayscale feature value for comparison with the scene switching threshold or the scene recognition threshold can be obtained, which has the advantage of less computational effort. At the same time, the scene detection scheme proposed in the embodiment of the present application does not rely on specific scenes, objects, and hardware equipment for acquisition, and only requires sufficient indoor and outdoor scene pictures for feature extraction training. It can be seen that the scheme provided in the embodiment of the present application is easy to operate, the detection principle is intuitive and easy to understand, and it has a wide range of applications, so it has great potential for promotion and dissemination. For example, in technical fields such as autonomous driving, the detection accuracy of indoor and outdoor scenes can be improved by applying this technical solution, thereby improving the performance and reliability of these applications.

[0159] Combination of the above Figures 1 to 8 , describes in detail the embodiment of the image-based scene detection method of the present application, and the following is combined with Fig. 9 , describe in detail the device embodiments of the present application.

[0160] Fig. 9 This is a schematic diagram of the structure of an image-based scene detection device provided in one embodiment of the present application. Fig.10 The image-based scene detection device 900 includes: a feature extraction module 910, a pixel screening module 920, a feature value determination module 930 and a feature value comparison module 940; wherein the feature extraction module 910 is used to extract features from the image to be tested and obtain the grayscale distribution information of the pixels in the image to be tested; the pixel screening module 920 is used to determine the pixels whose grayscale values ​​meet the preset conditions according to the grayscale distribution information to obtain the target pixel set; the feature value determination module 930 is used to determine the grayscale feature value of the image to be tested according to the grayscale values ​​of the pixels in the target pixel set; and the feature value comparison module 940 is used to compare the grayscale feature value corresponding to the image to be tested with the scene recognition threshold to obtain the scene detection result of the image to be tested; wherein the scene recognition threshold is determined according to the grayscale feature value corresponding to the image under different scenes.

[0161] In an exemplary embodiment, based on the above solution, the image-based scene detection device 900 further includes: a threshold calculation module; wherein the threshold calculation module includes: an acquisition unit, a calculation unit, and a determination unit;

[0162] The acquisition unit is used to acquire sample images under N scenes, where N is an integer greater than 1; the calculation unit is used to calculate the i-th grayscale eigenvalue corresponding to the i-th scene based on the sample images under the i-th scene, where i is a positive integer less than N; and the determination unit is used to determine the i-th scene recognition threshold based on the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue; wherein the i-th scene recognition threshold is used to compare with the grayscale eigenvalue corresponding to the image to be tested, so as to determine whether the image to be tested belongs to the i+1-th scene or the i-th scene.

[0163] In an exemplary embodiment, based on the above scheme, the above i-th scene includes M sub-scenes; the sample image under the above i-th scene includes M sub-sample images corresponding to the M sub-scenes, where M is an integer greater than 1;

[0164] The above-mentioned calculation unit includes a first calculation subunit and a second calculation subunit; wherein the above-mentioned first calculation subunit is used to: calculate the sub-grayscale eigenvalues ​​corresponding to the sub-sample images under the above-mentioned i-th scene respectively, and obtain M sub-grayscale eigenvalues; and the above-mentioned second calculation subunit is used to: determine the grayscale eigenvalue corresponding to the above-mentioned i-th scene according to the above-mentioned M sub-grayscale eigenvalues; wherein the above-mentioned second calculation subunit is specifically used to: determine the j-th weight corresponding to the M sub-scenes under the above-mentioned i-th scene respectively, wherein j is a positive integer not greater than M; perform weighted processing on the sub-grayscale eigenvalue corresponding to the j-th sub-scene by the above-mentioned j-th weight; and determine the grayscale eigenvalue corresponding to the above-mentioned i-th scene according to the sub-grayscale eigenvalue after weighted processing.

[0165] In an exemplary embodiment, based on the above scheme, the above determination unit is specifically used to: determine the i-th interval, wherein the upper limit value of the i-th interval is the grayscale feature value corresponding to the i+1-th scene, and the lower limit value of the i-th interval is the grayscale feature value corresponding to the i-th scene; and determine the i-th scene recognition threshold according to the i-th interval, wherein the i-th scene recognition threshold belongs to the i-th interval.

[0166] In an exemplary embodiment, based on the above scheme, after the above determination unit determines the i-th scene recognition threshold according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue, the above threshold calculation module also includes: a scene switching threshold calculation unit; wherein the above scene switching threshold calculation unit is used to: determine the i-th scene switching high threshold corresponding to the situation where the i-th scene switches to the i+1-th scene; and, determine the i-th scene switching low threshold corresponding to the situation where the i+1-th scene switches to the i-th scene; wherein the i-th scene switching high threshold is greater than the i-th scene switching low threshold, and the i-th scene recognition threshold is greater than the i-th scene switching high threshold.

[0167] In an exemplary embodiment, based on the above scheme, the scene switching threshold calculation unit is specifically used to: obtain a plurality of first sample images corresponding to the case where the i-th scene is switched to the i+1-th scene; obtain first sample grayscale feature values ​​corresponding to the first sample images; and determine the i-th scene switching high threshold according to the statistical value of the first sample grayscale feature values;

[0168] The scene switching threshold calculation unit is also specifically used to: obtain multiple second sample images corresponding to the situation where the i+1th scene switches to the i-th scene; obtain second sample grayscale feature values ​​corresponding to the second sample images; and determine the i-th scene switching low threshold value based on the statistical value of the second sample grayscale feature values; wherein the difference between the i-th scene switching high threshold value and the i-th scene switching low threshold value is greater than a preset value.

[0169] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes; the sample images in the indoor scenes belong to a first image set consisting of sub-sample images corresponding to P indoor sub-scenes, and the sample images in the outdoor scenes belong to a second image set consisting of sub-sample images corresponding to Q outdoor sub-scenes, where P and Q are positive integers;

[0170] The calculation unit is specifically used to: calculate P sub-grayscale feature values ​​corresponding to the P sub-sample images in the first image set, and determine the grayscale feature value corresponding to the indoor scene according to the P sub-grayscale feature values;

[0171] The above-mentioned determination unit is specifically used to: determine a first interval, wherein the upper limit value of the above-mentioned first interval corresponds to the grayscale eigenvalue of the outdoor scene, and the lower limit value of the above-mentioned first interval corresponds to the grayscale eigenvalue of the indoor scene; and determine the indoor and outdoor scene recognition threshold according to the above-mentioned first interval, wherein the above-mentioned indoor and outdoor scene recognition threshold belongs to the above-mentioned first interval.

[0172] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes; the threshold calculation module also includes a switching threshold calculation unit; after the determination unit determines the i-th scene recognition threshold according to the i-th grayscale eigenvalue and the i+1-th grayscale eigenvalue, the switching threshold calculation unit is used to: determine the first scene switching threshold corresponding to the situation where the indoor scene switches to the outdoor scene; and, determine the second scene switching threshold corresponding to the situation where the outdoor scene switches to the indoor scene; wherein the first scene switching threshold is greater than the second scene switching low threshold, and the indoor and outdoor scene recognition threshold is greater than the first scene switching high threshold.

[0173] In an exemplary embodiment, based on the above scheme, the N scenes include indoor scenes and outdoor scenes, and the i-th scene recognition threshold is an indoor and outdoor scene recognition threshold;

[0174] The above-mentioned comparison module 940 is specifically used to: compare the grayscale feature value of the above-mentioned image to be tested with the above-mentioned indoor and outdoor scene recognition threshold; if the grayscale feature value of the above-mentioned image to be tested is greater than the above-mentioned indoor and outdoor scene recognition threshold, the scene detection result is that the above-mentioned image to be tested belongs to the outdoor scene; if the grayscale feature value of the above-mentioned image to be tested is less than or equal to the above-mentioned indoor and outdoor scene recognition threshold, the scene detection result is that the above-mentioned image to be tested belongs to the indoor scene.

[0175] In an exemplary embodiment, based on the above solution, the above image-based scene detection device 900 further includes: an identification object determination module and an association module;

[0176] The recognition object determination module is used to: determine the recognition object corresponding to the recognition occasion according to the recognition occasion before the acquisition unit acquires the sample images under N scenes;

[0177] The acquisition unit is specifically used to: acquire sample images of the same type of identification object in N scenes respectively;

[0178] The association module is used to: after determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value, determine a first association relationship between the i-th scene recognition threshold and the corresponding recognition occasion;

[0179] The above-mentioned image-based scene detection device 900 further includes: an identification occasion determination module;

[0180] The recognition occasion determination module is used to determine the current recognition occasion before the comparison module 940 compares the grayscale feature value of the image to be tested with the scene recognition threshold;

[0181] The association module is used to obtain, according to the current recognition scenario, a scene recognition threshold value having a first association relationship with the current recognition scenario, so as to compare the scene recognition threshold value with the grayscale characteristic value of the image to be tested.

[0182] In an exemplary embodiment, based on the above scheme, there is a second association relationship between the target recognition occasion and the target recognition object, wherein the scene recognition threshold having the first association relationship with the above target recognition occasion is determined with respect to a sample image of the above target recognition object;

[0183] The above-mentioned image-based scene detection device 900 further includes: a recognition occasion determination module and a recognition object determination module;

[0184] The recognition occasion determination module is used to: determine the current recognition occasion before the feature extraction module 910 extracts features from the image to be tested; and determine the current recognition object having a second association relationship with the current recognition occasion according to the current recognition occasion;

[0185] The above-mentioned recognition object determination module is used to: determine whether the above-mentioned image to be tested contains the above-mentioned current recognition object; wherein, when the above-mentioned image to be tested contains the above-mentioned current recognition object, execute the step of extracting features from the image to be tested; the above-mentioned image-based scene detection device 900 also includes: an image acquisition module; the above-mentioned image acquisition module is used to: when the above-mentioned image to be tested does not contain the above-mentioned current recognition object, re-acquire the image to be tested; wherein, the above-mentioned image to be tested and the sample image used to determine the above-mentioned scene recognition threshold are both infrared images.

[0186] In an exemplary embodiment, based on the above scheme, the pixel screening module 920 is specifically used to: determine the total range of pixel grayscales in the image to be tested according to the grayscale distribution information; and determine a target range from the total range, wherein the grayscale values ​​of the pixels in the target range meet a preset condition, wherein the grayscale value of the pixel under the preset condition is greater than the grayscale value of other pixels in the total range except the target range, or the grayscale value of the pixel under the preset condition is less than the grayscale value of other pixels in the total range except the target range;

[0187] The above-mentioned characteristic value determination module 930 is specifically used to: perform integral calculation on the grayscale values ​​of the pixels in the above-mentioned target pixel set to obtain the integral value of the pixel; and determine the grayscale characteristic value of the above-mentioned image to be tested according to the above-mentioned integral value of the pixel.

[0188] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Fig. 9 The device shown can execute the above-mentioned embodiment of the image-based scene detection method, and the above-mentioned and other operations and / or functions of each module in the device corresponding to the method embodiment are not repeated here for the sake of brevity.

[0189] The above describes the device of the embodiment of the present application from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.

[0190] Fig.10 is a schematic block diagram of an electronic device provided in an embodiment of the present application, Fig.10 The electronic device may be used to perform the above-mentioned image-based scene detection method, and the electronic device may be the above-mentioned computing device, such as Figure 1 The computing device 104 is configured to:

[0191] like Fig.10 As shown, the electronic device 1000 may include:

[0192] The memory 1010 and the processor 1020, the memory 1010 is used to store the computer program 33 and transmit the program code 33 to the processor 1020. In other words, the processor 1020 can call and run the computer program 1030 from the memory 1010 to implement the method in the embodiment of the present application.

[0193] For example, the processor 1020 may be configured to execute the steps in the above method according to the instructions in the computer program 1030 .

[0194] In some embodiments of the present application, the processor 1020 may include but is not limited to:

[0195] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.

[0196] In some embodiments of the present application, the memory 1010 includes but is not limited to:

[0197] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).

[0198] In some embodiments of the present application, the computer program 1030 may be divided into one or more modules, which are stored in the memory 1010 and executed by the processor 1020 to complete the method for recording a page provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 1030 in the electronic device.

[0199] like Fig.10 As shown, the electronic device 1000 may further include:

[0200] The transceiver 1040 may be connected to the processor 1020 or the memory 1010 .

[0201] The processor 1020 may control the transceiver 1040 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 1040 may include a transmitter and a receiver. The transceiver 1040 may further include an antenna, and the number of antennas may be one or more.

[0202] It should be understood that the various components in the electronic device 1000 are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.

[0203] According to one aspect of the present application, a computer storage medium is provided, on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.

[0204] According to another aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method of the above method embodiment.

[0205] In other words, when implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.

[0206] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0207] In the several embodiments provided in the present application, 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 module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules 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 through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0208] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0209] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A scene detection method based on an image, characterized in that: The method comprises: Extracting features of the image to be tested to obtain grayscale distribution information of pixels in the image to be tested; According to the grayscale distribution information, pixels whose grayscale values ​​meet preset conditions are determined to obtain a target pixel set; Determining the grayscale characteristic value of the image to be tested according to the grayscale values ​​of the pixels in the target pixel set; The grayscale characteristic value of the image to be tested is compared with the scene recognition threshold to obtain the scene detection result of the image to be tested; wherein the scene recognition threshold is determined according to the grayscale characteristic value of the image under different scenes.

2. The method according to claim 1, characterized in that The method further comprises: Obtain sample images under N scenes, where N is an integer greater than 1; Calculate the i-th grayscale feature value corresponding to the i-th scene according to the sample image under the i-th scene, where i is a positive integer less than N; Determine an i-th scene recognition threshold according to an i-th grayscale eigenvalue and an i+1-th grayscale eigenvalue; The i-th scene recognition threshold is used to compare with the grayscale feature value corresponding to the image to be tested, so as to determine whether the image to be tested belongs to the (i+1)-th scene or the i-th scene.

3. The method according to claim 2, characterized in that The i-th scene includes M sub-scenes; the sample image under the i-th scene includes M sub-sample images corresponding to the M sub-scenes, where M is an integer greater than 1; The calculating, according to the sample image under the i-th scene, the i-th grayscale feature value corresponding to the i-th scene includes: Calculate the sub-grayscale feature values ​​corresponding to the sub-sample images in the i-th scene respectively to obtain M sub-grayscale feature values; Determine the j-th weights corresponding to the M sub-scenes under the i-th scene, where j is a positive integer not greater than M; Performing weighted processing on the sub-grayscale feature value corresponding to the j-th sub-scene by using the j-th weight; The grayscale feature value corresponding to the i-th scene is determined according to the weighted sub-grayscale feature values.

4. The method according to claim 2, characterized in that: The step of determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value includes: Determine an i-th interval, wherein an upper limit value of the i-th interval is a grayscale feature value corresponding to the (i+1)-th scene, and a lower limit value of the i-th interval is a grayscale feature value corresponding to the i-th scene; An i-th scene recognition threshold is determined according to the i-th interval, wherein the i-th scene recognition threshold belongs to the i-th interval.

5. The method according to claim 2, characterized in that: After determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value, the method further includes: Determine an i-th scene switching high threshold corresponding to a case where the i-th scene is switched to the (i+1)-th scene; Determine an i-th scene switching low threshold corresponding to a case where the i+1-th scene is switched to the i-th scene; The i-th scene switching high threshold is greater than the i-th scene switching low threshold, and the i-th scene recognition threshold is greater than the i-th scene switching high threshold.

6. The method according to claim 5, characterized in that The determining of an i-th scene switching high threshold corresponding to a situation where the i-th scene is switched to the (i+1)-th scene includes: Acquire a plurality of first sample images corresponding to a situation where the i-th scene is switched to the (i+1)-th scene; Obtaining a first sample grayscale characteristic value corresponding to the first sample image; Determining the i-th scene switching high threshold value according to the statistical value of the grayscale characteristic value of the first sample; The determining of the i-th scene switching lower threshold corresponding to the case where the i+1-th scene is switched to the i-th scene includes: Acquire a plurality of second sample images corresponding to a situation where the (i+1)th scene is switched to the (i)th scene; Obtaining a second sample grayscale characteristic value corresponding to the second sample image; Determining the i-th scene switching low threshold value according to the statistical value of the grayscale characteristic value of the second sample; The difference between the i-th scene switching high threshold and the i-th scene switching low threshold is greater than a preset value.

7. The method according to claim 2, characterized in that The N scenes include indoor scenes and outdoor scenes; the sample images in the indoor scenes belong to a first image set consisting of sub-sample images corresponding to P indoor sub-scenes, and the sample images in the outdoor scenes belong to a second image set consisting of sub-sample images corresponding to Q outdoor sub-scenes, where P and Q are positive integers; The calculating, according to the sample image under the i-th scene, the i-th grayscale feature value corresponding to the i-th scene includes: Calculating P sub-grayscale eigenvalues ​​corresponding to the P sub-sample images in the first image set, and determining the grayscale eigenvalue corresponding to the indoor scene according to the P sub-grayscale eigenvalues; The step of determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value includes: Determine a first interval, wherein an upper limit of the first interval is a grayscale feature value corresponding to an outdoor scene, and a lower limit of the first interval is a grayscale feature value corresponding to an indoor scene; An indoor and outdoor scene recognition threshold is determined according to the first interval, wherein the indoor and outdoor scene recognition threshold belongs to the first interval.

8. The method according to claim 7, characterized in that The N scenes include indoor scenes and outdoor scenes; After determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value, the method further includes: Determine a first scene switching threshold corresponding to a situation where the indoor scene is switched to the outdoor scene; Determine a second scene switching threshold corresponding to a situation where the outdoor scene is switched to the indoor scene; Among them, the first scene switching threshold is greater than the second scene switching low threshold, and the indoor and outdoor scene recognition threshold is greater than the first scene switching high threshold.

9. The method according to claim 2, characterized in that: The N scenes include indoor scenes and outdoor scenes, and the i-th scene recognition threshold is an indoor and outdoor scene recognition threshold; The step of comparing the grayscale feature value of the image to be tested with the scene recognition threshold to obtain the scene detection result of the image to be tested includes: Comparing the grayscale feature value of the image to be tested with the indoor and outdoor scene recognition threshold; If the grayscale feature value of the image to be tested is greater than the indoor and outdoor scene recognition threshold, the scene detection result is obtained that the image to be tested belongs to an outdoor scene; If the grayscale feature value of the image to be tested is less than or equal to the indoor and outdoor scene recognition threshold, the scene detection result is that the image to be tested belongs to an indoor scene.

10. The method according to claim 2, characterized in that Before acquiring the sample images under N scenes, the method further includes: Determine, according to the identification occasion, an identification object corresponding to the identification occasion; The obtaining of sample images under N scenes includes: Obtain sample images of the same type of identification object in N scenes; After determining the i-th scene recognition threshold according to the i-th grayscale feature value and the (i+1)-th grayscale feature value, the method further includes: Determine a first association relationship between the i-th scene recognition threshold and a corresponding recognition occasion; Before comparing the grayscale feature value of the image to be tested with the scene recognition threshold, the method further includes: Determine the current identification occasion; According to the current recognition occasion, a scene recognition threshold having a first correlation relationship with the current recognition occasion is obtained for comparison with the grayscale characteristic value of the image to be tested.

11. The method according to claim 10, characterized in that There is a second association relationship between the target recognition occasion and the target recognition object, wherein the scene recognition threshold having the first association relationship with the target recognition occasion is determined with respect to a sample image of the target recognition object; Before extracting features from the image to be tested, the method further includes: Determine the current identification occasion; According to the current recognition occasion, determining a current recognition object having a second association relationship with the current recognition occasion; Determining whether the image to be tested contains the current recognition object; Wherein, when the image to be tested contains the current identification object, the step of extracting features from the image to be tested is performed; when the image to be tested does not contain the current identification object, the image to be tested is reacquired; the image to be tested and the sample image used to determine the scene recognition threshold are both infrared images.

12. The method according to any one of claims 1 to 11, characterized in that The step of determining pixels whose grayscale values ​​meet a preset condition according to the grayscale distribution information to obtain a target pixel set includes: Determining a total range of pixel grayscales in the image to be tested according to the grayscale distribution information; Determine a target range from the total range, wherein the grayscale values ​​of pixels within the target range are pixels that meet a preset condition, wherein the grayscale value of the preset condition pixel is greater than the grayscale values ​​of other pixels in the total range except the target range, or the grayscale value of the preset condition pixel is less than the grayscale values ​​of other pixels in the total range except the target range; Determining the grayscale characteristic value of the image to be tested according to the grayscale value of the pixel in the target pixel set includes: Integrating the grayscale values ​​of the pixels in the target pixel set to obtain an integral value of the pixel; The grayscale characteristic value of the image to be tested is determined according to the integral value of the pixel.

13. A scene detection device based on an image, characterized in that: The device comprises: A feature extraction module is used to extract features of the image to be tested and obtain grayscale distribution information of pixels in the image to be tested; A pixel screening module, used to determine pixels whose grayscale values ​​meet preset conditions according to the grayscale distribution information, and obtain a target pixel set; A characteristic value determination module, used to determine the grayscale characteristic value of the image to be tested according to the grayscale value of the pixels in the target pixel set; The feature value comparison module is used to compare the grayscale feature value corresponding to the image to be tested with the scene recognition threshold to obtain the scene detection result of the image to be tested; wherein the scene recognition threshold is determined according to the grayscale feature value corresponding to the image under different scenes.

14. An electronic device, characterized in that: including a processor and a memory; The memory is used to store computer programs; The processor is used to execute the computer program to implement the image-based scene detection method as described in any one of claims 1 to 12 above.

15. A computer-readable storage medium, characterized in that: For storing computer programs; The computer program enables a computer to execute the image-based scene detection method as described in any one of claims 1 to 12 above.