Picture detection method, processing method and device, computer device and storage medium
Patent Information
- Application Number
- CN202111454862.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2041-12-01
AI Technical Summary
在高速运动、麻包件内密集堆放包裹、包裹高度方向尺寸变化时,可能会出现将一个包裹切割成两张图像的情况,这将对统计包裹数量、包裹图像与快递条码准确绑定等产生较大影响
[0058] The image detection method, processing method, device, computer equipment, and storage medium described above can detect whether continuously cut images are erroneously cut images, which helps to accurately count the number of packages and improve the accuracy of binding package barcodes with images.
Smart Images

Figure CN116205941B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, specifically to an item positioning method, apparatus, computer equipment, and readable storage medium. Background Technology
[0002] In public places such as logistics hubs, subway stations, airports, and train stations, security screening machines are commonly used to inspect parcels and luggage, using X-ray images to determine if they contain contraband. The security screening screen displays continuous video of parcel movement. Current solutions typically use the infrared detection device of the security screening machine to determine the start and end times of the parcel movement and then crop the image from that time frame. However, in high-speed security screening at logistics facilities, conveyor belt speeds can exceed 1.5 m / s, and there are issues such as densely packed parcels with varying shapes and sizes. High-speed movement, densely packed parcels within bulk packages, and changes in the height of the parcels can lead to a single parcel being split into two images. This can significantly impact parcel counting and the accurate binding of parcel images to courier barcodes. Summary of the Invention
[0003] Therefore, it is necessary to provide an image detection method, processing method, apparatus, computer equipment, and storage medium to address the aforementioned technical problems. This method can detect whether continuously cut images are incorrectly cut images, which helps to accurately count the number of packages and improve the accuracy of binding package barcodes with images.
[0004] Firstly, this application provides an image detection method, including:
[0005] A first item image and a second item image are obtained by continuously cutting the original image, wherein the first side column pixels of the first item image and the second side column pixels of the second item image are adjacent in the original image;
[0006] Extract the first pixel information of the first item image, starting from the first side column pixels and extending to a preset number of columns;
[0007] Extract the second pixel information from the second item image, starting from the second side column pixels and including a preset number of columns;
[0008] If the feature difference between the first pixel information and the second pixel information is less than or equal to a preset threshold, then the first item image and the second item image are determined to be images of the same item in the original image.
[0009] In some embodiments of this application, obtaining the first and second object images obtained by continuously cutting the original image includes:
[0010] Obtain the first and second cutting moments for cutting the original image, where the first and second cutting moments are the moments corresponding to two consecutive cuts.
[0011] If the time interval between the first cutting moment and the second cutting moment is less than or equal to a preset interval threshold, then the first item image obtained at the first cutting moment and the second item image obtained at the second cutting moment are acquired.
[0012] In some embodiments of this application, extracting the first pixel information of the first item image, starting from the first side column pixels and extending to a preset number of columns, includes:
[0013] The first item image is subjected to grayscale processing and background removal to obtain a first preprocessed image;
[0014] Extract the first pixel information of the first preprocessed image, starting from the first side column pixels and extending to a preset number of columns;
[0015] Extracting the second pixel information from the second item image, starting from the second side column pixels and extending to a preset number of columns, including:
[0016] The second item image is subjected to grayscale conversion and background removal to obtain a second preprocessed image;
[0017] Extract the second pixel information from the second preprocessed image, starting from the second side column pixels and including a preset number of columns.
[0018] In some embodiments of this application, the step of determining that the first item image and the second item image belong to the same item in the original image if the feature difference value between the first pixel information and the second pixel information is less than or equal to a preset threshold includes:
[0019] Calculate the first statistical feature value in the first pixel information and the second statistical feature value in the second pixel information;
[0020] If the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image; and / or,
[0021] Extract the first feature point of the first pixel information and the second feature point of the second pixel information;
[0022] If the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image.
[0023] In some embodiments of this application, the first statistical feature value is the average of the first features of each column of pixels in the first pixel information, and the second statistical feature value is the average of the second features of each column of pixels in the second pixel information. The step of determining that the first item image and the second item image belong to the same item in the original image if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold includes:
[0024] If at least one of the first pixel information and the second pixel information has only one column of pixels, then when the difference between the mean of the first feature and the mean of the second feature is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0025] If the first pixel information and the second pixel information contain multiple columns of pixels, then the first change trend of adjacent columns of pixels in the first pixel information is calculated based on the first feature mean, and the second change trend of adjacent columns of pixels in the second pixel information is calculated based on the second feature mean.
[0026] When the first change trend is the same as the second change trend, and the difference between the first feature mean of the first side column pixels and the second feature mean of the second side column pixels is less than or equal to a preset threshold, the first item image and the second item image are determined to be images of the same item in the original image.
[0027] In some embodiments of this application, the first statistical feature value is the first sequence distance between adjacent columns of pixels in the first pixel information, and the second statistical feature value is the second sequence distance between adjacent columns of pixels in the second pixel information. The step of determining that the first item image and the second item image belong to the same item in the original image if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold includes:
[0028] Calculate the third sequence distance between the first side column pixels and the second side column pixels;
[0029] If at least one of the first pixel information and the second pixel information has only one column of pixels, then when the distance of the third sequence is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image;
[0030] If both the first pixel information and the second pixel information contain multiple columns of pixels, then when the third sequence distance is between the first sequence distance and the second sequence distance, and the third sequence distance is less than or equal to a preset sequence distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0031] In some embodiments of this application, the first statistical feature value is a first histogram of the first pixel information, and the second statistical feature value is a second histogram of the second pixel information. The step of determining that if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image includes:
[0032] Calculate the histogram distance between the first histogram and the second histogram;
[0033] If at least one of the first pixel information and the second pixel information has only one column of pixels, then when the histogram distance is less than or equal to a preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0034] If both the first pixel information and the second pixel information contain multiple columns of pixels, then when the histogram distance change trend of the first histogram is the same as the histogram distance change trend of the second histogram, and the histogram distance is less than or equal to a preset histogram distance threshold, then it is determined that the first item image and the second item image belong to the same item in the original image.
[0035] In some embodiments of this application, the step of determining that if the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image includes:
[0036] Calculate the feature point distance between the first feature point and the second feature point;
[0037] If the distance between the feature points is less than or equal to a preset feature point distance threshold, then the first item image and the second item image belong to the same item in the original image.
[0038] Secondly, this application provides an image processing method, including:
[0039] The first item image and the second item image are detected using the image detection method described in any of the above methods;
[0040] When the first item image and the second item image belong to the same item in the same item image, the first item image and the second item image are stitched together.
[0041] Thirdly, this application provides an image detection device, comprising:
[0042] The image acquisition module is used to acquire a first item image and a second item image obtained by continuously cutting an original image, wherein the first side column pixels of the first item image and the second side column pixels of the second item image are adjacent in the original image;
[0043] The information extraction module is communicatively connected to the image acquisition module and is used to extract first pixel information from the first item image, starting from the first side column pixels and extending to a preset number of columns; and to extract second pixel information from the second item image, starting from the second side column pixels and extending to a preset number of columns.
[0044] The feature detection module, which is communicatively connected to the information extraction module, is used to determine that the first item image and the second item image belong to the same item in the original image if the feature difference value obtained by matching the first pixel information and the second pixel information is less than or equal to a preset threshold.
[0045] In some embodiments of this application, the image acquisition module is further configured to acquire a first cutting moment and a second cutting moment for cutting the original image, wherein the first cutting moment and the second cutting moment are the moments corresponding to two consecutive cuts; if the time interval between the first cutting moment and the second cutting moment is less than or equal to a preset interval threshold, then the first item image obtained by cutting at the first cutting moment and the second item image obtained by cutting at the second cutting moment are acquired.
[0046] In some embodiments of this application, the information extraction module is further configured to perform grayscale processing and background removal on the first item image to obtain a first preprocessed image; extract first pixel information from the first preprocessed image starting from the first side column pixels and a preset number of columns; perform grayscale processing and background removal on the second item image to obtain a second preprocessed image; and extract second pixel information from the second preprocessed image starting from the second side column pixels and a preset number of columns.
[0047] In some embodiments of this application, the feature detection module is further configured to calculate a first statistical feature value in the first pixel information and a second statistical feature value in the second pixel information; if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image; and / or, extract a first feature point of the first pixel information and a second feature point of the second pixel information; if the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image.
[0048] In some embodiments of this application, the feature detection module is further configured to: if at least one of the first pixel information and the second pixel information contains only one column of pixels, then when the difference between the first feature mean and the second feature mean is less than or equal to a preset threshold, determine that the first item image and the second item image belong to the same item in the original image; if the first pixel information and the second pixel information contain multiple columns of pixels, calculate a first change trend of adjacent columns of pixels in the first pixel information based on the first feature mean, and calculate a second change trend of adjacent columns of pixels in the second pixel information based on the second feature mean; when the first change trend is the same as the second change trend, and the difference between the first feature mean of the first side column pixels and the second feature mean of the second side column pixels is less than or equal to a preset threshold, determine that the first item image and the second item image belong to the same item in the original image.
[0049] In some embodiments of this application, the feature detection module is further configured to calculate a third sequence distance between the first side column pixels and the second side column pixels; if at least one of the first pixel information and the second pixel information contains only one column of pixels, then when the third sequence distance is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image; if both the first pixel information and the second pixel information contain multiple columns of pixels, then when the third sequence distance is between the first sequence distance and the second sequence distance, and the third sequence distance is less than or equal to a preset sequence distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0050] In some embodiments of this application, the feature detection module is further configured to calculate the histogram distance between the first histogram and the second histogram; if at least one of the first pixel information and the second pixel information contains only one column of pixels, then when the histogram distance is less than or equal to a preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image; if both the first pixel information and the second pixel information contain multiple columns of pixels, then when the histogram distance change trend of the first histogram is the same as the histogram distance change trend of the first histogram, and the histogram distance is less than or equal to the preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0051] In some embodiments of this application, the feature detection module is further configured to calculate the feature point distance between the first feature point and the second feature point; if the feature point distance is less than or equal to a preset feature point distance threshold, then the first item image and the second item image belong to the same item in the original image.
[0052] Fourthly, this application also provides a server, the server comprising:
[0053] One or more processors;
[0054] Memory; and
[0055] One or more applications, wherein the applications are stored in memory and configured to be executed by a processor to implement an image detection method.
[0056] Fifthly, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to execute steps in an image detection method.
[0057] Sixthly, embodiments of this application provide a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method provided in the first aspect.
[0058] The image detection method, processing method, device, computer equipment, and storage medium described above can detect whether continuously cut images are erroneously cut images, which helps to accurately count the number of packages and improve the accuracy of binding package barcodes with images. Attached Figure Description
[0059] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0060] Figure 1 This is a schematic diagram of a scene using the image detection method in an embodiment of this application;
[0061] Figure 2 This is a flowchart illustrating the image detection method in an embodiment of this application;
[0062] Figure 3 This is a schematic diagram illustrating the extraction of an existing preset number of pixel sequences in an embodiment of this application;
[0063] Figure 4 This is a schematic diagram of the background color pixels of the additional preset number column in the embodiments of this application;
[0064] Figure 5 This is a flowchart illustrating the image processing method in an embodiment of this application;
[0065] Figure 6 This is a schematic diagram of the image detection device in the embodiments of this application;
[0066] Figure 7 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0067] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0068] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0069] In the description of this application, the word "for example" is used to mean "used as an example, illustration, or description." Any embodiment described as "for example" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0070] In this application's embodiments, the image detection method primarily involves Computer Vision (CV) technology within Artificial Intelligence (AI). Artificial intelligence utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to achieve optimal results—a set of theories, methods, technologies, and application systems. In other words, artificial intelligence is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine capable of reacting in a manner similar to human intelligence.
[0071] Computer vision is the science that studies how to enable machines to "see." More specifically, it refers to machine vision, which uses cameras and computers to replace human eyes in recognizing, tracking, and measuring targets, and then performs image processing to create images more suitable for human observation or transmission to instruments. As a scientific discipline, computer vision studies related theories and technologies, attempting to build artificial intelligence systems capable of extracting information from images or multidimensional data. Computer vision technologies typically include image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, 3D object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), and common biometric recognition technologies such as facial recognition and fingerprint recognition.
[0072] In the embodiments of this application, it should be noted that since the image detection method provided in this application is executed in a computer device, the processing objects of each computer device exist in the form of data or information, such as time, which is essentially time information. It can be understood that if size, quantity, position, etc. are mentioned in subsequent embodiments, they are all corresponding data that exist so that the computer device can process them. The specifics will not be elaborated here.
[0073] In the embodiments of this application, it should also be noted that the image detection method provided in the embodiments of this application can be applied to, for example, Figure 1 The image detection system shown includes a terminal 100 and a server 200. The terminal 100 can be a device that includes both receiving and transmitting hardware, meaning it has receiving and transmitting hardware capable of performing bidirectional communication over a two-way communication link. This device can include cellular or other communication devices with single-line displays, multi-line displays, or no multi-line displays. Specifically, the terminal 100 can be a desktop terminal or a mobile terminal, specifically a mobile phone, tablet computer, laptop computer, or a camera installed at the monitoring site for information collection, storage, and transmission. The server 200 can be a standalone server or a server network or server cluster, including but not limited to computers, network hosts, single network servers, multiple network server sets, or cloud servers composed of multiple servers. The cloud server consists of a large number of computers or network servers based on cloud computing.
[0074] Those skilled in the art will understand that Figure 1 The application environment shown is merely one application scenario of the solution in this application and does not constitute a limitation on the application scenario of the solution in this application. Other application environments may include those that are more specific to this application. Figure 1 The number of computer devices shown is more or less, for example Figure 1 Only one server (200) is shown in the image; it is understood that this image detection system may include one or more other servers, which are not specified here. Additionally, as... Figure 1 As shown, the image detection system may also include a memory for storing data, such as security inspection video information.
[0075] It should also be noted that, Figure 1 The schematic diagram of the image detection system shown is merely an example. The image detection system and scenario described in this embodiment are intended to more clearly illustrate the technical solutions of this embodiment and do not constitute a limitation on the technical solutions provided by this embodiment. As those skilled in the art will know, with the evolution of image detection systems and the emergence of new business scenarios, the technical solutions provided by this embodiment are also applicable to similar technical problems.
[0076] See Figure 2 This application provides an image detection method, which is mainly applied to the above-mentioned... Figure 1 Taking server 200 as an example, the method includes steps S201 to S204, as follows:
[0077] S201, Obtain a first item image and a second item image obtained by continuously cutting the original image, wherein the first side column pixels of the first item image and the second side column pixels of the second item image are adjacent in the original image.
[0078] The security inspection equipment acquires continuous video of the movement of items. When it is necessary to obtain an image of each item, the image of the corresponding item is usually obtained by cropping the original image corresponding to the video of the item's movement. In other words, the original image is the image corresponding to the video of the item's movement.
[0079] The first and second item images are obtained by cutting the original image. The first and second item images are adjacent and continuous images in the original image. The first side column pixels of the first item image and the second side column pixels of the second item image are adjacent in the original image. That is to say, the first and second item images are obtained by cutting between the first and second side column pixels of the original image.
[0080] The first item image is identified by detecting and analyzing the original image, confirming that a single item is contained within the corresponding image region of the original image; this is the first item. The second item image is identified by detecting and analyzing the original image, confirming that a single item is contained within the corresponding image region of the original image; this is the second item.
[0081] It should be noted that by segmenting each original image corresponding to the entire video of the item's movement, several item images are obtained, each containing an independent item. Based on these segmented item images, it is easier to identify and analyze prohibited items individually, and also facilitates express delivery and logistics operations such as counting package quantities and accurately binding package images with express barcodes.
[0082] Specifically, before the server 200 executes the image detection task, the user can send a task request to the server 200 through the terminal 100. The task request carries images of a first item and a second item that need to be identified. After receiving the task request, the server 200 can perform detection and analysis based on the first and second item images according to the image detection method. Alternatively, before executing the image detection task, the server 200 does not need to receive the task request sent by the terminal 100. In this case, the terminal 100 is a camera with a camera function. After the terminal 100 periodically or in real-time acquires the first and second item images, it can send them to the server 200 to execute the image detection task. Furthermore, the terminal 100 can be equipped with an image acquisition device. The terminal 100 periodically or in real-time acquires video or images, captures the first and second item images, and sends them to the server 200 so that the server 200 can execute the image detection task.
[0083] In one embodiment, this step includes: S301, obtaining a first cutting time and a second cutting time for cutting the original image, wherein the first cutting time and the second cutting time are the times corresponding to two consecutive cuts; S302, if the time interval between the first cutting time and the second cutting time is less than or equal to a preset interval threshold, then obtaining the first item image obtained by cutting at the first cutting time and the second item image obtained by cutting at the second cutting time.
[0084] When items pass through continuously, the security inspection equipment captures video of the items' movement and saves the corresponding timestamps. Therefore, the generation time of each image segmented from the original image is saved. When the generation time interval between two consecutive images is relatively short, it may indicate that the same package has been mistakenly segmented into two images. The system determines whether the images belong to the same package by comparing whether the time interval between two consecutive images is less than a set threshold. Therefore, the system acquires the timestamps corresponding to the two consecutive segmentations of the original image—the first segmentation time and the second segmentation time. If the time interval between the first and second segmentations is less than or equal to a preset threshold, the system acquires the first item image obtained at the first segmentation time and the second item image obtained at the second segmentation time. Further analysis then determines whether the first and second item images are mistakenly segmented images.
[0085] In real-world scenarios, the preset interval threshold is related to factors such as conveyor belt speed and average package size. The preset interval threshold can be customized according to different situations. Choosing a larger preset interval threshold helps to pre-screen potentially mis-cut packages and images, pushing them to the next step for further processing, thus reducing computational load. For example, in a high-speed logistics security inspection scenario, setting the time interval between two consecutive images to less than 0.5 seconds indicates a suspected mis-cut image, which then proceeds to subsequent steps for further processing.
[0086] S202, extract the first pixel information of the first item image, starting from the first side column pixels and extending to a preset number of columns.
[0087] In this case, the ending portion of the first image and the beginning portion of the second image in two consecutive mis-segmented images can be seamlessly stitched together; that is, the first side column pixels of the first object image and the second side column pixels of the second object image can be seamlessly stitched together. The first side column pixels of the first object image and the second side column pixels of the second object image show strong correlations in statistical features, key point features, and correlations. Therefore, these aspects can be used to determine whether consecutive first and second object images are mis-segmented images.
[0088] Pixel information stores the pixel values of key columns, which can be one or more columns. To ensure accuracy, retaining multiple columns is preferred. Therefore, the first pixel information of the first item image is extracted, starting from the first side column pixels, for a preset number of columns, where the preset number of columns can be one or more. Depending on the requirements of subsequent feature calculations, the preset number of columns for the first pixel information can refer to directly extracting existing preset number columns, or it can be retaining the first side column pixels of the first item image and then supplementing with a preset number of background color pixels. Figure 3 As shown, the leftmost 5 columns of pixel information, starting from the first side column of the first item image, can be retained as the first pixel information, forming sequence set B. Figure 4 As shown, multiple columns of background images are added to the right of the first item image to expand the image.
[0089] In one embodiment, this step includes: S401, performing grayscale processing and background removal on the first item image to obtain a first preprocessed image; S402, extracting the first pixel information of the first preprocessed image, starting from the first side column pixels and a preset number of columns.
[0090] In this embodiment, the solution is not significantly related to image color, but rather to edges, contour gradients, etc. Therefore, the first image of the first object is first converted to grayscale. After grayscale conversion, the dimension of the image matrix decreases, the processing speed increases, and gradient information is still preserved.
[0091] Furthermore, most of the video footage of moving objects acquired by security inspection equipment has a solid color background, such as a white background in X-ray images. Therefore, to further reduce the amount of data processing in subsequent analysis, background removal can be performed on the first object image. When removing the background color, the removal depends on the direction of object movement in the video. Background removal is performed on the area of the first object image perpendicular to the direction of object movement. For example, when the object moves to the left or right, background removal is performed on the top and bottom sides of the first object image, while the left and right sides are left unprocessed. Specifically, this is divided into two parts: top-side traversal and bottom-side traversal. Taking top-to-bottom traversal as an example, the difference in pixel values between adjacent rows is compared. If the difference in pixel values is greater than a threshold, the traversal stops, the background area on the top is removed, and the valid envelope area on the bottom is retained. Euclidean distance can be used to measure the difference between pixel values in two rows. When traversing from bottom to top, the background area at the bottom is removed, and the valid envelope area at the top is retained. This removes the background areas at the top and bottom, retaining the valid area in the middle. Top-to-bottom traversal can be performed simultaneously to improve boundary search efficiency. This method, by setting a reasonable threshold, is sensitive to the boundaries of the package and will not accidentally cut out the package image when removing the background.
[0092] S203, extract the second pixel information of the second item image, starting from the second side column pixels and including a preset number of columns.
[0093] In this case, the ending portion of the first image and the beginning portion of the second image in two consecutive mis-segmented images can be seamlessly stitched together; that is, the first side column pixels of the first object image and the second side column pixels of the second object image can be seamlessly stitched together. The first side column pixels of the first object image and the second side column pixels of the second object image show strong correlations in statistical features, key point features, and correlations. Therefore, these aspects can be used to determine whether consecutive first and second object images are mis-segmented images.
[0094] Pixel information stores the pixel values of key columns, which can be one or more columns. To ensure accuracy, retaining multiple columns is preferred. Therefore, the second pixel information of the second item image is extracted, starting from the second side column pixels, for a preset number of columns, where the preset number of columns can be one or more. Depending on the requirements of subsequent feature calculations, the preset number of columns for the second pixel information can refer to directly extracting existing preset number columns, or it can be retaining the second side column pixels of the second item image and then supplementing them with a preset number of background color pixels. Figure 3 As shown, the rightmost 5 columns of pixel information, starting from the second side column of the second item image, can be retained as the second pixel information, forming sequence set A. For example... Figure 4 As shown, multiple columns of background images are added to the left of the second item image to expand the image.
[0095] It should be noted that the preset quantity column of the second pixel information may or may not be the same as the preset quantity column of the first pixel information.
[0096] In one embodiment, this step includes: S501, performing grayscale processing and background removal on the second item image to obtain a second preprocessed image; S502, extracting second pixel information from the second preprocessed image, starting from the second side column pixels and including a preset number of columns.
[0097] In this embodiment, the solution is not significantly related to image color, but rather to edges, contour gradients, etc. Therefore, the second item image is first converted to grayscale. Grayscale conversion reduces the dimension of the image matrix, increases the computation speed, and still preserves gradient information.
[0098] Furthermore, most of the video footage of moving objects acquired by security inspection equipment has a solid color background, such as a white background in X-ray images. Therefore, to further reduce the amount of data processing in subsequent analysis, background removal can be performed on the second object image. When removing the background color, the removal depends on the direction of object movement in the video footage. Background removal is performed on the area of the second object image perpendicular to the direction of object movement. For example, when the object moves to the left or right, background removal is performed on the top and bottom sides of the second object image, while the left and right sides are left unprocessed. Specifically, this is divided into two parts: top-side traversal and bottom-side traversal. Taking top-to-bottom traversal as an example, the difference in pixel values between adjacent rows is compared. If the difference exceeds a threshold, the traversal stops, the top background area is removed, and the effective envelope area on the bottom is retained. Euclidean distance can be used to measure the difference between pixel values in two rows. When traversing from bottom to top, the bottom background area is removed, and the effective envelope area on top is retained. This removes the top and bottom background areas while retaining the effective area in the middle. Top and bottom traversals can be performed simultaneously to improve boundary search efficiency. This method, by setting a reasonable threshold, is sensitive to the boundaries of the package and will not accidentally cut out the package image when removing the background.
[0099] S204, if the feature difference value between the first pixel information and the second pixel information is less than or equal to a preset threshold, then it is determined that the first item image and the second item image belong to the same item in the original image.
[0100] In this scenario, the end portion of the preceding image and the beginning portion of the following image can be seamlessly stitched together from two consecutive mis-segmented images. Specifically, the first side column pixels of the first item image and the second side column pixels of the second item image can be seamlessly stitched together. The first and second side column pixels of the first and second item images exhibit strong correlations in statistical features, key point features, and correlation. Therefore, the presence of mis-segmented images can be determined by analyzing the first and second side column pixels. Furthermore, if the feature difference between the first and second pixel information is less than or equal to a preset threshold, the first and second item images are determined to belong to the same item in the original image. Different preset thresholds are set based on different types of feature difference values, and different preset thresholds can be set for different scenarios.
[0101] In one embodiment, this step includes: S601, calculating a first statistical feature value in the first pixel information and a second statistical feature value in the second pixel information; S602, if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image; and / or, S603, extracting a first feature point from the first pixel information and a second feature point from the second pixel information; S604, if the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image.
[0102] There are two types of analysis methods for the feature difference values of the first pixel information and the second pixel information: one is to calculate based on the features of each column of pixels in the first pixel information and the second pixel information, and the other is to perform matching calculations based on individual feature points in the first pixel information and the second pixel information.
[0103] It should be noted that in the process of identifying whether the first and second item images belong to the same item in the original image, only one method can be used for judgment, or multiple methods can be combined for judgment. When multiple methods are used for judgment, the result exceeding a predetermined number of judgments is taken as the final result. For example, when three methods are used for judgment, the result where at least two methods agree is selected as the final result.
[0104] Specifically, when calculating based on the features of each column of pixels in the first and second pixel information, since pixels have multiple features, the first statistical feature value in the first pixel information and the second statistical feature value in the second pixel information are calculated separately. If the difference between the first and second statistical feature values is less than or equal to a preset threshold, then the first and second object images belong to the same object in the original image. Similarly, different preset thresholds are set based on different types of pixel features. Furthermore, different preset thresholds can be set for different scenarios.
[0105] Specifically, when performing matching calculations based on individual feature points in the first pixel information and the second pixel information, feature points at the edge connection are extracted, that is, the first feature point of the first pixel information and the second feature point of the second pixel information are extracted.
[0106] In some cases, because certain feature points or key points may be located in the outermost column, image processing operators may fail to extract them. To accurately extract feature points at edge connections, multiple columns of background color pixels are added at these connections. In the first item image, starting from the first side column pixels, a predetermined number of background color pixels are added; in the second item image, starting from the second side column pixels, another predetermined number of background color pixels are added. After adding the predetermined number of background color pixels, these feature points are no longer at the outermost edge of the image, thus improving the accuracy of extracting these feature points or key points. Figure 4 As shown, multiple columns of background images are added to the right of the first item image and the left of the second item image to expand the image. Depending on the extraction operator, generally more than two columns of background images are added at the edges.
[0107] In one embodiment, step S602, if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image. The first statistical feature value is the first feature mean of each column of pixels in the first pixel information, and the second statistical feature value is the second feature mean of each column of pixels in the second pixel information, includes: S701, if at least one of the first pixel information and the second pixel information has only one column of pixels, then when the difference between the first feature mean and the second feature mean is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image; S702, if the first pixel information and the second pixel information contain multiple columns of pixels, then a first change trend of adjacent columns of pixels in the first pixel information is calculated based on the first feature mean, and a second change trend of adjacent columns of pixels in the second pixel information is calculated based on the second feature mean; S703, when the first change trend is the same as the second change trend, and the difference between the first feature mean of the first side column pixels and the second feature mean of the second side column pixels is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0108] The first statistical feature is the mean of the first feature of each column of pixels in the first pixel information, and the second statistical feature is the mean of the second feature of each column of pixels in the second pixel information. The first and second feature means are statistical feature values for each column of pixels, including but not limited to the number of non-background pixels, mean, standard deviation, variance, median, and coefficient of variation. The number of non-background pixels is the number of valid pixels remaining after removing the background color from each column of pixels. The mean is the mean of the grayscale values of the remaining valid pixels after removing the background color from each column of pixels. The standard deviation and variance are the standard deviation or variance of the grayscale values of the remaining valid pixels after removing the background color from each column of pixels, respectively. The median is the median of the grayscale values of the remaining valid pixels after removing the background color from each column of pixels. The coefficient of variation is the coefficient of variation of the grayscale values of the remaining valid pixels after removing the background color from each column of pixels. The coefficient of variation is the ratio of the standard deviation to the mean. Any one or more of these statistical feature values can be selected for subsequent classification.
[0109] Specifically, if at least one of the first and second pixel information contains only one column of pixels, then a single-column calculation is performed. This means the calculation is based solely on the feature values of the first and second side-column pixels. The first feature mean is the statistical feature value of the first side-column pixels, and the second feature mean is the statistical feature value of the second side-column pixels. When the difference between the first and second feature means is less than or equal to a preset threshold, the first and second item images are determined to belong to the same item in the original image. However, single-column calculations are susceptible to errors due to random factors.
[0110] Specifically, when both the first and second pixel information contain multiple columns of pixels, these multiple columns of pixels represent the original image sequence in the object image. Multi-column calculation is used, which includes comparing the statistical feature differences between adjacent columns and comparing the changing trends of consecutive columns. The first statistical feature value is the mean of the first features of each column of pixels in the first pixel information. Based on the mean of the first features, the first changing trend of adjacent columns of pixels in the first pixel information is calculated, that is, determining whether the statistical feature value of adjacent columns of pixels in the first pixel information gradually increases or gradually decreases in a certain direction. Similarly, the second statistical feature value is the mean of the second features of each column of pixels in the second pixel information. Based on the mean of the second features, the second changing trend of adjacent columns of pixels in the second pixel information is calculated, that is, determining whether the statistical feature value of adjacent columns of pixels in the second pixel information gradually increases or gradually decreases in a certain direction. When determining the first and second changing trends, it is necessary to select the same direction to judge the changes in adjacent columns of pixels.
[0111] When the first trend and the second trend are the same, the difference between the first feature mean of the first side column pixels and the second feature mean of the second side column pixels is further analyzed. If the difference between the first feature mean of the first side column pixels and the second feature mean of the second side column pixels is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image. The preset threshold can be set based on different scenarios and different types of statistical feature values, or it can be set based on the difference between adjacent columns of pixels in the first and second pixel information. For example, the average difference between the feature mean values of adjacent columns of pixels in the first or second pixel information, combined with the corresponding allowable error range, can be set as the preset threshold.
[0112] In one embodiment, step S602, if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image, where the first statistical feature value is the first sequence distance between adjacent columns of pixels in the first pixel information and the second statistical feature value is the second sequence distance between adjacent columns of pixels in the second pixel information, includes: S801, calculating the third sequence distance between the first side column pixels and the second side column pixels; S802, if at least one of the first pixel information and the second pixel information has only one column of pixels, then when the third sequence distance is less than or equal to the preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image; S803, if both the first pixel information and the second pixel information contain multiple columns of pixels, then when the third sequence distance is between the first sequence distance and the second sequence distance, and the third sequence distance is less than or equal to the preset sequence distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0113] The first statistical feature value is the first sequence distance between adjacent columns of pixels in the first pixel information, the second statistical feature value is the second sequence distance between adjacent columns of pixels in the second pixel information, and the third sequence distance between the first side column pixels and the second side column pixels is calculated.
[0114] Extract the grayscale value of each pixel in the pixel column, and then calculate the distance between corresponding pixels to obtain the sequence distance. Selectable similarity comparison distances include: Euclidean distance, Manhattan distance, Chebyshev distance, Minkowski distance, standardized Euclidean distance, Mahalanobis distance, cosine similarity, Hamming distance, Jaccard distance, correlation coefficient, and correlation distance.
[0115] To address the issue of adjacent pixel columns having different lengths, the shorter pixel column is first selected as the complete sequence during distance calculation. Then, it is used to iterate through and calculate the distance with the longer pixel column. The minimum distance calculated is compared to a set threshold. For example, if pixel column A1 has a length of n1 and pixel column B1 has a length of n2, and n1 > n2, then during distance calculation, the pixel column of length n2 in A1 is sequentially selected and its distance is calculated with that in B1, iterating n1-n2 times. The minimum distance among these steps is then taken as the effective distance.
[0116] If at least one of the first and second pixel information contains only one column of pixels, then only one of the first and second sequence distances exists, and it is impossible to determine the trend of change by combining the third sequence distance. Therefore, when the third sequence distance is less than or equal to a preset threshold, it is determined that the first and second item images belong to the same item in the original image.
[0117] If both the first and second pixel information contain multiple columns of pixels, then the first sequence distance and the second sequence distance are included simultaneously, and the third sequence distance is combined to determine the numerical magnitude and trend of change.
[0118] If both the first pixel information and the second pixel information contain two columns of pixels, then both the first sequence distance and the second sequence distance contain only one sequence distance value. When the third sequence distance is between the first sequence distance and the second sequence distance, and the third sequence distance is less than or equal to a preset sequence distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0119] If at least one of the first and second pixel information contains more than two columns of pixels, and at least one of the first and second sequence distances contains two sequence distance values, then it is determined that the adjacent sequence distances from the first sequence distance to the third sequence distance and then back to the second sequence distance exhibit the same trend of change. Furthermore, if the third sequence distance is less than or equal to a preset sequence distance threshold, then the first and second item images are determined to belong to the same item in the original image. The preset sequence distance threshold can be set based on different scenarios or based on the difference between adjacent sequence distances. For example, the average of the differences between all adjacent sequence distances, combined with the corresponding allowable error range, can be set as the preset sequence distance threshold.
[0120] In one embodiment, step S602, if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image, wherein the first statistical feature value is a first histogram of the first pixel information and the second statistical feature value is a second histogram of the second pixel information, includes: S901, calculating the histogram distance between the first histogram and the second histogram; S902, if at least one of the first pixel information and the second pixel information has only one column of pixels, then when the histogram distance is less than or equal to a preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image; S903, if both the first pixel information and the second pixel information contain multiple columns of pixels, then when the histogram distance change trend of the first histogram is the same as the histogram distance change trend of the first histogram, and the histogram distance is less than or equal to a preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0121] In this model, a first histogram is defined with first statistical feature values representing the information of the first pixel, and a second histogram is defined with second statistical feature values representing the information of the second pixel. The histogram distance between the first and second histograms is calculated. After obtaining the histograms, they are normalized to the same scale space. Then, the similarity between the two histograms is obtained by calculating the distance between them, and the similarity between neighboring images is then compared. Similarity calculation methods include correlation comparison and chi-square comparison.
[0122] If at least one of the first and second pixel information contains only one column of pixels, then at least one of the corresponding first and second histograms will contain only one histogram, making it impossible to determine the trend of histogram distance change. Therefore, when the histogram distance is less than or equal to a preset histogram distance threshold, the first and second item images are determined to belong to the same item in the original image.
[0123] If both the first and second pixel information contain multiple columns of pixels, then both the first and second histograms contain at least two histograms, thus allowing for simultaneous judgment of both numerical magnitude and trend.
[0124] If both the first pixel information and the second pixel information contain two columns of pixels, then both the first and second histograms contain two histograms. The first histogram distance between the two histograms in the first histogram and the second histogram distance between the two histograms in the second histogram are calculated. When the histogram distance is between the first histogram distance and the second histogram distance, and the histogram distance is less than or equal to a preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0125] If at least one of the first and second pixel information contains more than two columns of pixels, then the histogram distance change trend of the first histogram is the same as that of the second histogram. Simultaneously, if the histogram distance is less than or equal to a preset histogram distance threshold, then the first and second item images are determined to belong to the same item in the original image. The preset histogram distance threshold can be set based on different scenarios or based on the difference between adjacent histogram distances. For example, the average of the differences between all adjacent histogram distances, combined with the corresponding allowable error range, can be used as the preset histogram distance threshold.
[0126] In all the above embodiments, when there are only one or two determination features (feature mean, sequence distance, and histogram distance), only the numerical value needs to be determined. That is, when the determination features (difference between the feature mean of the first side column pixel and the second side column pixel, sequence distance, and histogram distance) corresponding to the first side column pixel and the second side column pixel are less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0127] When there are more than two features (feature mean, sequence distance, and histogram distance), both the magnitude and trend of the values need to be determined. Only when the overall trend is the same and the values are less than or equal to a preset threshold are the first and second item images determined to belong to the same item in the original image. For example, the first feature mean includes feature mean N1 and N2, and the second feature mean includes feature mean M1 and M2. N2 corresponds to the first side column pixels, and M1 corresponds to the second side column pixels. Then, when N1, N2, M1 to M2 increase or decrease sequentially, and the difference between N2 and M1 is less than or equal to a preset threshold, the first and second item images are determined to belong to the same item in the original image. The preset threshold can be freely set, or it can be based on the difference between N1 and N2 or the difference between M1 and M2. For example, the difference between N2 and M1 and the difference between N1 and N2 should be within a preset error range.
[0128] In one embodiment, step S604, if the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image, includes: S1001, calculating the feature point distance between the first feature point and the second feature point; S1002, if the feature point distance is less than or equal to a preset feature point distance threshold, then the first item image and the second item image belong to the same item in the original image.
[0129] The process involves calculating the feature point distance between the first and second feature points, extracting feature points from the first and second item images using image feature point detection methods, and saving only the feature points at the connection points for matching. Optional feature point detection methods include SIFT, SURF, and ORB algorithms. Furthermore, corner points are a type of feature point; they are points in a grayscale image where brightness changes drastically in different directions. Corner point detection methods are used to extract corner points from the first and second item images, saving only the corner points at the connection points for matching to reduce computational load. Optional corner point detection methods include Harris, KLT, SUSAN, Kitchen-Rosenfeld, and FAST algorithms. If the feature point distance is less than or equal to a preset feature point distance threshold, the first and second item images are considered to belong to the same item in the original image.
[0130] This embodiment can detect whether consecutive images are incorrectly cut, which helps to accurately count the number of packages and improve the accuracy of binding package barcodes to images. Unlike existing image detection methods that require a certain degree of overlap between the two images, this embodiment can effectively solve the problem of detecting images without overlap. In addition to being used for the detection and merging of incorrectly cut X-ray images, it is also applicable to natural light or other types of images, and has a wide range of applicability. Based on modular construction and the integration of multiple processing methods, each module or method can be used individually or in combination, providing a high degree of flexibility.
[0131] See Figure 5 This application provides an image processing method, including:
[0132] S210, the first item image and the second item image are detected by the image detection method as described in any of the above embodiments;
[0133] S220, when it is determined that the first item image and the second item image belong to the same item in the same item image, the first item image and the second item image are stitched together.
[0134] In this embodiment, when detecting the first and second item images using the image detection method described above, a similar background removal process affecting image size is performed on both images. Therefore, when it is determined that the first and second item images belong to the same item within the same image, the initial state of the first and second item images is stitched together. Since the initial state of the first and second item images is obtained by cutting from the original image, the adjacent parts of the first and second item images have the same size, and they can be directly aligned and stitched together.
[0135] To better implement the projection image adjustment method in the embodiments of this application, based on the image detection method, the embodiments of this application also provide an image detection device, such as... Figure 6 As shown, the image detection device 900 includes:
[0136] Image acquisition module 910 is used to acquire a first item image and a second item image obtained by continuously cutting an original image, wherein the first side column pixels of the first item image and the second side column pixels of the second item image are adjacent in the original image;
[0137] The information extraction module 920 is communicatively connected to the image acquisition module 910 and is used to extract first pixel information from the first item image, starting from the first side column pixels and extending to a preset number of columns; and to extract second pixel information from the second item image, starting from the second side column pixels and extending to a preset number of columns.
[0138] The feature detection module 930, which is communicatively connected to the information extraction module 920, is used to determine that the first item image and the second item image belong to the same item in the original image if the feature difference value obtained by matching the first pixel information and the second pixel information is less than or equal to a preset threshold.
[0139] In some embodiments of this application, the image acquisition module 910 is further configured to acquire a first cutting moment and a second cutting moment for cutting the original image, wherein the first cutting moment and the second cutting moment are the moments corresponding to two consecutive cuts; if the time interval between the first cutting moment and the second cutting moment is less than or equal to a preset interval threshold, then the first item image obtained by cutting at the first cutting moment and the second item image obtained by cutting at the second cutting moment are acquired.
[0140] In some embodiments of this application, the information extraction module 920 is further configured to perform grayscale processing and background removal on the first item image to obtain a first preprocessed image; extract first pixel information from the first preprocessed image starting from the first side column pixels and a preset number of columns; perform grayscale processing and background removal on the second item image to obtain a second preprocessed image; and extract second pixel information from the second preprocessed image starting from the second side column pixels and a preset number of columns.
[0141] In some embodiments of this application, the feature detection module 930 is further configured to calculate a first statistical feature value in the first pixel information and a second statistical feature value in the second pixel information; if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image; and / or, extract a first feature point of the first pixel information and a second feature point of the second pixel information; if the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image.
[0142] In some embodiments of this application, the feature detection module 930 is further configured to: if at least one of the first pixel information and the second pixel information contains only one column of pixels, then when the difference between the first feature mean and the second feature mean is less than or equal to a preset threshold, determine that the first item image and the second item image belong to the same item in the original image; if the first pixel information and the second pixel information contain multiple columns of pixels, calculate a first change trend of adjacent columns of pixels in the first pixel information based on the first feature mean, and calculate a second change trend of adjacent columns of pixels in the second pixel information based on the second feature mean; when the first change trend is the same as the second change trend, and the difference between the first feature mean of the first side column pixels and the second feature mean of the second side column pixels is less than or equal to a preset threshold, determine that the first item image and the second item image belong to the same item in the original image.
[0143] In some embodiments of this application, the feature detection module 930 is further configured to calculate a third sequence distance between the first side column pixels and the second side column pixels; if at least one of the first pixel information and the second pixel information has only one column of pixels, then when the third sequence distance is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image; if both the first pixel information and the second pixel information contain multiple columns of pixels, then when the third sequence distance is between the first sequence distance and the second sequence distance, and the third sequence distance is less than or equal to a preset sequence distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0144] In some embodiments of this application, the feature detection module 930 is further configured to calculate the histogram distance between the first histogram and the second histogram; if at least one of the first pixel information and the second pixel information contains only one column of pixels, then when the histogram distance is less than or equal to a preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image; if both the first pixel information and the second pixel information contain multiple columns of pixels, then when the histogram distance change trend of the first histogram is the same as the histogram distance change trend of the first histogram, and the histogram distance is less than or equal to the preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
[0145] In some embodiments of this application, the feature detection module 930 is further configured to calculate the feature point distance between the first feature point and the second feature point; if the feature point distance is less than or equal to a preset feature point distance threshold, then the first item image and the second item image belong to the same item in the original image.
[0146] In some embodiments of this application, the image detection device 900 can be implemented as a computer program, and the computer program can be implemented in, for example... Figure 7 The image detection device 900 runs on the computer device shown. The computer device's memory can store the various program modules that make up the image detection device 900, for example, Figure 6 The image acquisition module 910, information extraction module 920, and feature detection module 930 are shown. The computer program comprised of these modules causes the processor to execute the steps of the image detection methods in the various embodiments of this application described in this specification.
[0147] For example, Figure 7 The computer equipment shown can be used as follows Figure 6The image acquisition module 910 in the image detection device 900 shown executes step S201. The computer device can execute steps S202 and S203 via the information extraction module 920. The computer device can execute step S204 via the feature detection module 930. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communication with external computer devices via a network connection. When the computer program is executed by the processor, it implements an image detection method.
[0148] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0149] In some embodiments of this application, a computer device is provided, including one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processors using the steps of the image detection method described above. The steps of the image detection method here may be steps from the image detection methods of the various embodiments described above.
[0150] In some embodiments of this application, a computer-readable storage medium is provided, storing a computer program. The computer program is loaded by a processor, causing the processor to execute the steps of the image detection method described above. The steps of the image detection method here can be the steps from the image detection methods of the various embodiments described above.
[0151] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0152] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0153] The foregoing has provided a detailed description of an image detection method, processing method, apparatus, computer device, and storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. An image detection method, characterized in that, include: Obtain the first cutting time and the second cutting time of the original image. If the time interval between the first cutting time and the second cutting time is less than or equal to a preset interval threshold, then obtain the first item image obtained by cutting at the first cutting time and the second item image obtained by cutting at the second cutting time. The first side column pixels of the first item image and the second side column pixels of the second item image are adjacent in the original image. Extract the first pixel information of the first item image, starting from the first side column pixels and extending to a preset number of columns; Extract the second pixel information from the second item image, starting from the second side column pixels and including a preset number of columns; If the feature difference value between the first pixel information and the second pixel information is less than or equal to a preset threshold, then the first item image and the second item image are determined to be images of the same item in the original image; wherein, the feature difference value is calculated based on the features or feature points of each column of pixels in the first pixel information and the second pixel information.
2. The image detection method as described in claim 1, characterized in that, The first cutting time and the second cutting time are the times corresponding to two consecutive cuts.
3. The image detection method as described in claim 1 or 2, characterized in that, The step of extracting the first pixel information from the first item image, starting from the first side column pixels and extending to a preset number of columns, includes: The first item image is subjected to grayscale processing and background removal to obtain a first preprocessed image; Extract the first pixel information of the first preprocessed image, starting from the first side column pixels and extending to a preset number of columns; Extracting the second pixel information from the second item image, starting from the second side column pixels and extending to a preset number of columns, including: The second item image is subjected to grayscale conversion and background removal to obtain a second preprocessed image; Extract the second pixel information from the second preprocessed image, starting from the second side column pixels and including a preset number of columns.
4. The image detection method as described in claim 3, characterized in that, The condition that if the feature difference between the first pixel information and the second pixel information is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image include: Calculate the first statistical feature value in the first pixel information and the second statistical feature value in the second pixel information; If the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image; and / or, Extract the first feature point of the first pixel information and the second feature point of the second pixel information; If the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image.
5. The image detection method as described in claim 4, characterized in that, The first statistical feature value is the mean of the first features of each column of pixels in the first pixel information, and the second statistical feature value is the mean of the second features of each column of pixels in the second pixel information. The step of determining that the first item image and the second item image belong to the same item in the original image if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold includes: If at least one of the first pixel information and the second pixel information has only one column of pixels, then when the difference between the mean of the first feature and the mean of the second feature is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image. If the first pixel information and the second pixel information contain multiple columns of pixels, then the first change trend of adjacent columns of pixels in the first pixel information is calculated based on the first feature mean, and the second change trend of adjacent columns of pixels in the second pixel information is calculated based on the second feature mean. When the first change trend is the same as the second change trend, and the difference between the first feature mean of the first side column pixels and the second feature mean of the second side column pixels is less than or equal to a preset threshold, the first item image and the second item image are determined to be images of the same item in the original image.
6. The image detection method as described in claim 4, characterized in that, The first statistical feature value is the first sequence distance between adjacent columns of pixels in the first pixel information, and the second statistical feature value is the second sequence distance between adjacent columns of pixels in the second pixel information. The statement that if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold, then the first item image and the second item image belong to the same item in the original image includes: Calculate the third sequence distance between the first side column pixels and the second side column pixels; If at least one of the first pixel information and the second pixel information has only one column of pixels, then when the distance of the third sequence is less than or equal to a preset threshold, it is determined that the first item image and the second item image belong to the same item in the original image; If both the first pixel information and the second pixel information contain multiple columns of pixels, then when the third sequence distance is between the first sequence distance and the second sequence distance, and the third sequence distance is less than or equal to a preset sequence distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image.
7. The image detection method as described in claim 4, characterized in that, The first statistical feature value is a first histogram of the first pixel information, and the second statistical feature value is a second histogram of the second pixel information. The step of considering the first item image and the second item image as images belonging to the same item in the original image if the difference between the first statistical feature value and the second statistical feature value is less than or equal to a preset threshold includes: Calculate the histogram distance between the first histogram and the second histogram; If at least one of the first pixel information and the second pixel information has only one column of pixels, then when the histogram distance is less than or equal to a preset histogram distance threshold, it is determined that the first item image and the second item image belong to the same item in the original image. If both the first pixel information and the second pixel information contain multiple columns of pixels, then when the histogram distance change trend of the first histogram is the same as the histogram distance change trend of the second histogram, and the histogram distance is less than or equal to a preset histogram distance threshold, then it is determined that the first item image and the second item image belong to the same item in the original image.
8. The image detection method as described in claim 4, characterized in that, The condition that if the first feature point and the second feature point match, then the first item image and the second item image belong to the same item in the original image include: Calculate the feature point distance between the first feature point and the second feature point; If the distance between the feature points is less than or equal to a preset feature point distance threshold, then the first item image and the second item image belong to the same item in the original image.
9. An image processing method, characterized in that, include: The first item image and the second item image are detected by the image detection method as described in any one of claims 1 to 8 above; When it is determined that the first item image and the second item image belong to the same item in the same item image, the first item image and the second item image are stitched together.
10. An image detection device, characterized in that, include: The image acquisition module is used to acquire the first cutting time and the second cutting time of the original image. If the time interval between the first cutting time and the second cutting time is less than or equal to a preset interval threshold, the first item image obtained by cutting at the first cutting time and the second item image obtained by cutting at the second cutting time are acquired. The first side column pixels of the first item image and the second side column pixels of the second item image are adjacent in the original image. The information extraction module is communicatively connected to the image acquisition module and is used to extract the first pixel information of the first item image, starting from the first side column pixels and extending to a preset number of columns. Extract the second pixel information from the second item image, starting from the second side column pixels and including a preset number of columns; The feature detection module, which is communicatively connected to the information extraction module, is used to determine that the first item image and the second item image belong to the same item in the original image if the feature difference value obtained by matching the first pixel information and the second pixel information is less than or equal to a preset threshold; wherein, the feature difference value is calculated based on the features or feature points of each column of pixels in the first pixel information and the second pixel information.
11. A computer device, characterized in that, The computer device includes: One or more processors; The memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the image detection method of any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to perform the steps of the image detection method according to any one of claims 1 to 8.
Citation Information
Patent Citations
A package image segmentation method for security inspection and a corresponding security inspection device
CN109410226A