Image detection method and system based on machine vision

Through a machine vision-based image detection method, a dual-branch poultry egg detection model was established using hyperspectral and visible light images, which solved the problem of low efficiency of manual detection of poultry egg cracks, achieved automated and accurate poultry egg detection, and improved production efficiency.

CN120599472APending Publication Date: 2025-09-05WENHUA UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510715358.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

In the existing technology, crack detection of poultry eggs relies on manual inspection, which is time-consuming and labor-intensive, inefficient and seriously wastes resources.

Method used

A machine vision-based image detection method was adopted. By collecting hyperspectral images and visible light images of poultry eggs, a dual-branch poultry egg detection model was established after preprocessing, including feature fusion of the unmixing encoder, Swin Transformer and spatial transformer network. Finally, the detection results were output through the Transformer network.

Benefits of technology

It realizes the automatic, rapid and accurate detection of whether poultry eggs have cracks, improves the detection efficiency, reduces manual intervention and ensures the quality of poultry eggs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120599472A_ABST
    Figure CN120599472A_ABST
Patent Text Reader

Abstract

The invention provides an image detection method and system based on machine vision. The method comprises the following steps: acquiring a hyperspectral image and a visible light image of the same target poultry egg; preprocessing the hyperspectral image and visible light of the target poultry egg by adopting a denoising and normalization mode, and dividing the collected images of the same target poultry egg into a training set and a test set; establishing a double-branch poultry egg detection model; putting the processed data into the established model for training to obtain a preliminary double-branch poultry egg detection model; adjusting the network structure and network parameters of the model, and re-training the preliminary double-branch poultry egg detection model to obtain an optimal double-branch poultry egg detection model; and carrying out image preprocessing on the target poultry egg by using the test set in a denoising and normalization mode, transmitting the preprocessed hyperspectral image of the target poultry egg and visible light into the optimal double-branch poultry egg detection model, and outputting an image detection result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine vision, and in particular to an image detection method and system based on machine vision. Background Art

[0002] In recent years, with the rapid development of machine vision technologies and significant improvements in the performance of various hardware devices, image detection and processing technology has been widely used in nearly every industry, even in our daily lives, and is playing an increasingly important role. This research focuses on using computers to automatically process large amounts of sensory information (including sound, images, and video) instead of humans. This addresses the vulnerability of human visual perception to environmental factors, mood, fatigue, and other factors, thereby partially replacing manual labor and significantly improving production efficiency. Currently, poultry egg production is almost entirely centralized industrial production, which makes manual identification of cracked eggs complex and difficult on a large scale. Manual identification is time-consuming, labor-intensive, and wastes significant resources. Summary of the Invention

[0003] In response to the shortcomings of the existing technology, the purpose of the present invention is to propose an image detection method based on machine vision. By applying machine vision technology to egg crack detection, machine vision is extended to the human eye, so that it has the judgment ability of the human brain to a certain extent, replacing the manual distinction of whether there is an egg crack in an automated way to ensure the quality of the eggs.

[0004] On the one hand, a method for image detection based on machine vision is provided, comprising the following steps: Step S1, collecting a hyperspectral image and a visible light image of the same target poultry egg; Step S2: preprocessing the hyperspectral image and visible light of the target poultry eggs using methods including denoising and normalization, and dividing the collected images of the same target poultry eggs into a training set and a test set; Step S3, establishing a double-branch egg detection model; Step S4: putting the data processed in step S2 into the model established in step S3 for training to obtain a preliminary double-branch egg detection model; Step S5: adjusting the network structure and network parameters of the model, and retraining the preliminary two-branch poultry and egg detection model to obtain the optimal two-branch poultry and egg detection model; Step S6: Using the test set in step S2, perform image preprocessing on it by denoising and normalization, pass the preprocessed hyperspectral image and visible light of the target poultry eggs into the optimal two-branch poultry egg detection model, and output the image detection results.

[0005] Preferably, in step S3, establishing the dual-branch egg detection model includes: inputting the hyperspectral image of the target egg into an unmixing encoder to obtain endmember features and abundance features of the hyperspectral image.

[0006] Preferably, the constraints of the demixing encoder are that the abundance map satisfies non-negativity and the sum of the abundances is 1.

[0007] Preferably, the establishing of the dual-branch egg detection model includes: inputting the visible light image of the target egg into Swin Transformer to obtain texture features of the visible light image.

[0008] Preferably, the establishing of the dual-branch egg detection model includes: inputting the endmember features and texture features into a spatial transformation network for registration transformation to dynamically align the endmember features of the hyperspectral image and the texture features of the visible light image.

[0009] Preferably, the establishing of the dual-branch egg detection model includes: fusing the endmember features of the aligned hyperspectral image and the texture features of the visible light image to obtain multimodal features.

[0010] Preferably, the establishing of the double-branch egg detection model includes: position encoding the multimodal features to obtain an encoded multimodal feature sequence.

[0011] Preferably, the establishing of the dual-branch egg detection model includes: inputting the encoded multimodal feature sequence into a Transformer network for training to output a detection result.

[0012] On the other hand, the present invention also provides a system and electronic device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the computer program, the steps of the above-mentioned image detection method based on machine vision are implemented.

[0013] The present invention proposes an image detection method based on machine vision, which comprises the following steps: collecting a hyperspectral image and a visible light image of the same target poultry egg; preprocessing the hyperspectral image and the visible light image of the target poultry egg by using a denoising and normalization method, and dividing the collected images of the same target poultry egg into a training set and a test set; establishing a double-branch poultry egg detection model; placing the processed data into the established model for training to obtain a preliminary double-branch poultry egg detection model; adjusting the network structure and network parameters of the model, and retraining the preliminary double-branch poultry egg detection model to obtain an optimal double-branch poultry egg detection model; performing image preprocessing on the test set by using a denoising and normalization method, transmitting the preprocessed hyperspectral image and visible light image of the target poultry egg into the optimal double-branch poultry egg detection model, and outputting the image detection result. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 A flow chart of an image detection method based on machine vision provided by the present invention; Figure 2 A double-branched egg detection model provided by the present invention; Figure 3 This is a schematic diagram of the physical structure of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0015] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0016] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.

[0017] Example 1 like Figure 1 As shown, this embodiment provides an image detection method based on machine vision, which includes the following steps: Step 1: Collect hyperspectral images of poultry eggs and collect visible light images of poultry eggs. Collecting hyperspectral images of poultry eggs specifically includes setting up a spectral acquisition system, which includes a computer, a spectrometer, a darkroom, a light source, a bracket, a stage, and poultry eggs. A halogen tungsten lamp or LED light source is used to provide light to stimulate the spectral signal of the poultry eggs. A hyperspectral camera covering the visible and near-infrared spectral range is used to collect spectra in a darkroom environment to obtain a hyperspectral image of the poultry eggs. Collecting visible light images of poultry eggs specifically includes selecting a high-resolution industrial camera and using manual focus to ensure a clear image of the poultry eggs. Step 2: Preprocess the hyperspectral and visible light images of the target eggs using methods including denoising and normalization. The collected images of the same target egg are then divided into training and test sets. In step 2, denoising the hyperspectral and visible light images can be performed using morphological filtering, which processes the images through a series of morphological operations (such as dilation, erosion, opening, and closing). In egg image processing, morphological filtering can be used to enhance crack features and remove noise, particularly in edge detection and feature extraction, where it offers unique advantages. Alternatively, median filtering can be used to denoise the hyperspectral and visible light images. This method replaces the value of each pixel in the image with the median of its neighboring pixels, thereby eliminating isolated noise points. In egg image processing, median filtering can effectively remove salt-and-pepper noise caused by cracks and scratches while preserving edge information. Therefore, median filtering is a suitable filtering method for egg crack detection. The hyperspectral image and visible light image of the target poultry eggs are preprocessed by normalization. Specifically, the image data is normalized using the Min-Max normalization method. For hyperspectral images, each band needs to be processed separately, while for visible light images, the entire image can be processed uniformly. For hyperspectral images and visible light images, the value of each pixel can be regarded as a data point. Each original pixel is linearly transformed to the range [0,1] using the following formula (1). The normalization formula is as follows: (1) Among them, X is the original data, and are the minimum and maximum values ​​in the data set, respectively. is the normalized data.

[0018] Step 3: Establish a double-branch egg detection model. Figure 2 As shown, Figure 2 A double-branch poultry egg detection model is provided in this embodiment; in this step 3, the establishment of the double-branch poultry egg detection model includes inputting the hyperspectral image of the target poultry egg into an unmixing encoder to obtain the end member features and abundance features of the hyperspectral image, and the constraints of the unmixing encoder are that the abundance map satisfies non-negativity and the sum of the abundances is 1.

[0019] The described establishment of a dual-branch poultry and egg detection model also includes inputting the visible light image of the target poultry and eggs into SwinTransformer to obtain the texture features of the visible light image. Specifically, the Swin Transformer realizes multi-scale, cross-window texture feature extraction through windowed multi-head self-attention and alternating window offset mechanisms. Windowed multi-head self-attention is to divide the visible light image into non-overlapping windows of size M*M, and perform self-attention calculations independently in each window, so that the calculation of attention can be limited to the window, reducing computational complexity while retaining the local fine-grained feature interaction capability. Alternating window offset is in adjacent Transformer layers, and the window position is offset according to rules. For example, the Lth layer uses conventional window division, and the L+1th layer offsets the window to the lower right corner by M / 2 pixels. If the edge area may be incomplete after the offset, the number of windows is ensured to be consistent by annular filling, and the filling area is restored after calculation. By offsetting the inter-layer window, cross-window information fusion is achieved to capture the global context.

[0020] Establishing the dual-branch egg detection model also includes inputting the endmember features and texture features into a spatial transformation network for a registration transformation to dynamically align the endmember features of the hyperspectral image with the texture features of the visible light image. Specifically, a transformation generated by the spatial transformation network is applied to the hyperspectral feature map to spatially align it with the visible light feature map. Alternatively, this can be performed using a multi-scale pyramid registration approach. Specifically, the spatial transformation network is applied at multiple feature scales (e.g., 1 / 4, 1 / 8, and 1 / 16 resolution) to gradually refine the registration results. This approach can address the trade-off between large-scale deformation and computational efficiency.

[0021] The dual-branch egg detection model is established by fusing the endmember features of the aligned hyperspectral image and the texture features of the visible light image to obtain multimodal features. During the alignment process, an attention mechanism (such as cross attention) is introduced to dynamically adjust the transformation parameters, calculate the attention weights of the hyperspectral features (Query) and the visible light features (Key / Value), and generate fused features. In the process of generating fused features, a registration loss function can be introduced. The registration loss function can be used to constrain the pixel-level alignment of the transformed hyperspectral image and the visible light image. The registration loss function is shown in Formula (2): (2) The dual-branch egg detection model is established by positionally encoding multimodal features to obtain an encoded multimodal feature sequence. Specifically, a unified global position index is assigned to all modalities (e.g., numbered in order of modal appearance), a global position code is generated, and the features of each modality are fused and then added to the global position code.

[0022] The establishment of the dual-branch poultry egg detection model includes inputting the encoded multimodal feature sequence into a Transformer network for training to output a detection result.

[0023] like Figure 2 As shown, this embodiment provides an image detection method based on machine vision, which includes: Step S1, collecting a hyperspectral image and a visible light image of the same target poultry egg; Step S2: preprocessing the hyperspectral image and visible light of the target poultry eggs using methods including denoising and normalization, and dividing the collected images of the same target poultry eggs into a training set and a test set; Step S3, establishing a double-branch egg detection model; Step S4: putting the data processed in step S2 into the model established in step S3 for training to obtain a preliminary double-branch egg detection model; Step S5: adjusting the network structure and network parameters of the model, and retraining the preliminary two-branch poultry and egg detection model to obtain the optimal two-branch poultry and egg detection model; Step S6: Using the test set in step S2, perform image preprocessing on it by denoising and normalization, pass the preprocessed hyperspectral image and visible light of the target poultry eggs into the optimal two-branch poultry egg detection model, and output the image detection results.

[0024] Example 2 like Figure 3 FIG2 is a schematic diagram of the physical structure of an electronic device provided by the present invention. The electronic device may include: a processor 301, a memory 302, a communication interface 303, and a communication bus 304, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus. The processor can call logic instructions in the memory to execute the image detection method of the present invention, which includes: collecting hyperspectral images and visible light images of the same target poultry egg; preprocessing the hyperspectral images and visible light images of the target poultry egg using a denoising and normalization method, and dividing the collected images of the same target poultry egg into a training set and a test set; establishing a dual-branch poultry egg detection model; putting the processed data into the established model for training to obtain a preliminary dual-branch poultry egg detection model; adjusting the network structure and network parameters of the model, and then retraining the preliminary dual-branch poultry egg detection model to obtain an optimal dual-branch poultry egg detection model; using the test set to preprocess the image using a denoising and normalization method, transferring the preprocessed hyperspectral images and visible light images of the target poultry egg to the optimal dual-branch poultry egg detection model, and outputting the image detection results.

[0025] In summary, the present invention proposes an image detection method based on machine vision, which establishes a dual-branch poultry egg detection model. First, the endmember features and texture features are input into a spatial transformation network for registration transformation to dynamically align the endmember features of the hyperspectral image and the texture features of the visible light image. Then, the endmember features of the aligned hyperspectral image and the texture features of the visible light image are fused to obtain multimodal features. Finally, the encoded multimodal feature sequence is input into a Transformer network for training to output the detection results.

[0026] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0027] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0028] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a specific manner as specified in the instructions, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0029] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a specific manner as specified in the instructions, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0030] It should be noted that the technical features in the above embodiments can be combined in any way, and the technical solutions formed by the combination all fall within the scope of protection of this application. In this article, terms such as "including", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including a..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0031] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. An image detection method based on machine vision, characterized in that: The steps include: Step S1, collecting a hyperspectral image and a visible light image of the same target poultry egg; Step S2, preprocessing the hyperspectral image and visible light image of the target poultry eggs using methods including denoising and normalization, and dividing the collected images of the same target poultry eggs into a training set and a test set; Step S3, establishing a double-branch egg detection model; Step S4: putting the data processed in step S2 into the model established in step S3 for training to obtain a preliminary double-branch egg detection model; Step S5: adjusting the network structure and network parameters of the model, and retraining the preliminary two-branch poultry and egg detection model to obtain the optimal two-branch poultry and egg detection model; Step S6: Using the test set in step S2, perform image preprocessing on it by denoising and normalization, pass the preprocessed hyperspectral image and visible light of the target poultry eggs into the optimal dual-branch poultry egg detection model, and output the image detection results.

2. The image detection method based on machine vision according to claim 1, characterized in that: In step S3, establishing a dual-branch poultry egg detection model includes: inputting the hyperspectral image of the target poultry egg into an unmixing encoder to obtain endmember features and abundance features of the hyperspectral image.

3. The image detection method based on machine vision according to claim 1, characterized in that: The constraints of the demixing encoder are that the abundance map satisfies non-negativity and the sum of the abundances is 1.

4. The machine vision-based image detection method according to claim 2, wherein: The establishment of the dual-branch poultry egg detection model includes: inputting the visible light image of the target poultry egg into Swin Transformer to obtain texture features of the visible light image.

5. The machine vision-based image detection method according to claim 4, wherein: The establishment of the dual-branch egg detection model includes: inputting the endmember features and texture features into a spatial transformation network for registration transformation to dynamically align the endmember features of the hyperspectral image and the texture features of the visible light image.

6. The machine vision-based image detection method according to claim 5, wherein: The method for establishing a dual-branch poultry egg detection model includes: fusing endmember features of the aligned hyperspectral image and texture features of the visible light image to obtain multimodal features.

7. The machine vision-based image detection method according to claim 6, wherein: The establishment of the double-branch poultry egg detection model includes: position encoding the multimodal features to obtain an encoded multimodal feature sequence.

8. The machine vision-based image detection method according to claim 7, wherein: The establishment of the dual-branch poultry egg detection model includes: inputting the encoded multimodal feature sequence into a Transformer network for training to output a detection result.

9. A machine vision image detection system, the system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the machine vision-based image detection method as described above is implemented.