A detection method, storage medium and device based on an OPENCV reagent cover opening angle
By using OPENCV image processing technology to automatically detect the opening and closing status and angle of reagent caps, the problems of low efficiency and poor consistency caused by manual judgment are solved, and efficient and stable reagent cap operation is achieved.
Patent Information
- Application Number
- CN202211403680.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-10
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-11-10
AI Technical Summary
In existing technologies, the determination of the opening and closing angle of the reagent cap in the novel coronavirus detection method relies on manual operation, resulting in low efficiency, unstable process and low consistency.
Using OPENCV image processing technology, through image preprocessing, grayscale processing, binarization processing, mathematical morphology processing, and elliptical detection area design, the system automatically determines the opening and closing status and angle of the reagent cap, and uses a computer program to achieve automated detection.
It enables automatic judgment of the open/closed state of reagent caps and angle calculation, improving detection efficiency and ensuring the stability and consistency of the production process.
Smart Images

Figure CN115641328B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of image detection technology, and particularly relates to a detection method, a storage medium and a device for the opening angle of a reagent cover based on OPENCV. BACKGROUND
[0002] The detection methods for the novel coronavirus mainly include nucleic acid detection, antibody detection and antigen detection, but currently, whether the tip head cover of a reagent is opened and the approximate opening angle of the cover are determined manually, and if the opening angle does not meet the requirements, the position of the cover needs to be manually specified, and the reagent injection arm needs to be controlled to perform the opening operation until the opening requirements are met. The manual determination operation is low in efficiency, unstable in process, and low in consistency and accuracy. SUMMARY
[0003] The application aims to provide a detection method, a storage medium and a device for the opening angle of a reagent cover based on OPENCV to solve the problems in the technical background.
[0004] The application provides a detection method for the opening angle of a reagent cover based on OPENCV.
[0005] (1) An image A is obtained by photographing a hole plate region before each injection;
[0006] (2) An image B in an effective range is obtained by preprocessing the image;
[0007] (3) A graph C is obtained by performing gray scale processing on the image by using OPENCV;
[0008] (4) An image D is obtained by performing binary processing on the image by using OPENCV;
[0009] (5) An image E is obtained by performing mathematical morphology processing on the image;
[0010] (6) An image G is obtained by designing an elliptical detection region;
[0011] (7) A detection region is selected;
[0012] (8) The state of the reagent cover is determined.
[0013] Further, the step (2) is specifically that four vertex coordinates of the image are read, the width and the height of the image are calculated according to the four vertex coordinates, the effective region of a rectangle is defined by using the left upper vertex coordinate and the width and the height of the image, the effective region is cropped, and the image B in the effective range is obtained.
[0014] Further, the step (3) is: the image B can be obtained by using the cvtColor method of OPENCV image processing technology, and the image C is obtained by using the cvtColor method of OPENCV image processing technology.
[0015] Further, the step (4) is: first, select a suitable binary threshold, set all pixel values of the pixel points higher than the threshold in the gray image C to 255, and set all pixel values of the pixel points lower than the binary threshold to 0, and the binary image D is obtained by using the threshold method of OPENCV image processing technology.
[0016] Further, the step (5) is: first, the image D is subjected to an expansion operation, then subjected to a corrosion operation, and finally, the reagent cover contour image E is obtained by using the erode method of OPENCV image processing technology.
[0017] Further, the step (6) comprises the following steps:
[0018] (61) read the center point coordinates and the major and minor axis lengths of eight positions of the image E, and draw an ellipse in each of the eight positions by using the ellipse method of OPENCV image processing technology, and the pixel value of the drawn ellipse region is 0, which is black;
[0019] (62) clone the image E by using the clone method of OPENCV image processing technology, to obtain the image F, and read the ellipse region by using the subtract() method of OPENCV image processing technology, to obtain the image G.
[0020] Further, the step (7) comprises the following steps:
[0021] (71) divide the image A into two parts according to the horizontal coordinate and four parts according to the vertical coordinate, to obtain the coordinates of each position, and the selected eight detection regions for judging whether there is a cover are named as a first type of detection region;
[0022] (72) mark the positions of the eight ellipse graphs in the image G according to the first type of detection region;
[0023] (73) replace the ellipse detection region with the circumscribed rectangle of the ellipse, and name the eight circumscribed rectangle detection regions as a second type of detection region.
[0024] Further, the step (8) comprises the following steps:
[0025] (81) In Figure E, iterate through the number of white pixels in each of the eight Class I detection areas, that is, compare the pixel value of each pixel. When the pixel value is 255, increment the number of pixels in that area by 1 until all eight Class I detection areas have been traversed. Select a threshold of 15000. When the number of pixels in a certain Class I detection area is lower than the threshold, it can be determined that there is no cover. Use the putText() function to mark it as red 'Empty'.
[0026] (82) Traverse the number of white pixels in the 8 Class II detection regions in Figure G, calculate the ratio of the number of detected white pixels to the area of the elliptical region, and then pass the ratio to the arccos() function to calculate the opening angle of the lid. Mark the calculated opening angle below the lid and mark the ellipse as green.
[0027] The present invention also provides a storage medium storing a computer program, wherein the computer program is configured to execute any of the methods described above when it is run.
[0028] The present invention also provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform any of the methods described above.
[0029] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: it realizes the automatic judgment of the opening and closing state of the reagent tip cap, calculates the opening and closing angle of the cap and marks the angle, eliminates the cost of manual judgment, improves the efficiency of reagent injection, and makes the stability and consistency of the entire production process higher. Attached Figure Description
[0030] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0031] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0032] like Figure 1 As shown in the embodiment of the present invention, a method for detecting the opening and closing angle of a reagent cap based on OPENCV includes the following steps:
[0033] (1) Install the camera at a vertical distance of 30-35cm from the horizontal plane of the 8-well plate of the injection, and at a straight distance of 40-50cm from the 8-well plate of the injection, at a 45-degree angle downwards; take a picture of the well plate area before each injection to obtain image A.
[0034] (2) preprocessing the image, reading the four vertex coordinates of the image, calculating the width and height of the image according to the four vertex coordinates, defining the effective area of the rectangle with the upper left vertex coordinates and the width and height of the image, clipping the effective area to obtain the image B in the effective range.
[0035] (3) using OPENCV to perform grayscale processing on the image, specifically: using the cvtColor method of the OPENCV image processing technology, the image B can be obtained after grayscale transformation.
[0036] (4) using OPENCV to perform binaryzation processing on the image, specifically: first select a suitable binaryzation threshold, set all pixel values of pixel points higher than the threshold in the grayscale image to 255, and set all pixel values of pixel points lower than the binaryzation threshold to 0, and use the threshold method of OPENCV image processing technology to obtain the binaryzation image D.
[0037] (5) performing mathematical morphology processing on the image, specifically: first performing dilation operation on the image D, then performing erosion operation, and finally using the erode method of OPENCV image processing technology to obtain the reagent cover contour image E;
[0038] (6) designing an elliptical detection area to obtain image G, including the following steps:
[0039] (61) reading the center point coordinates and major and minor axis lengths of eight positions of image E, using the ellipse method of OPENCV image processing technology to draw ellipses at the eight positions, and the pixel values of the drawn elliptical regions are 0, which are black.
[0040] (62) using the clone method of OPENCV image processing technology to clone picture E to obtain picture F, and using the subtract() method of OPENCV image processing technology to read the elliptical region to obtain picture G;
[0041] (7) selecting a detection area, including the following steps:
[0042] (71) dividing picture A into two parts according to the horizontal coordinate and four parts according to the vertical coordinate, and obtaining the coordinates of each position, and selecting eight detection areas for judging whether there is a cover, which are named as a type of detection area;
[0043] (72) marking the positions of the eight elliptical graphs in picture G according to the a type of detection area;
[0044] (73) using the circumscribed rectangle of the ellipse to replace the elliptical detection area, and naming the eight circumscribed rectangle detection areas as a type of detection area;
[0045] (8) judging the reagent cover state, comprising the following steps:
[0046] (81) In Figure E, the number of white pixel points in each of the eight first-type detection zones is counted, i.e. the pixel value of each pixel point is compared, when the pixel value is 255 (range: 0-255), the number of pixel points in the region is increased by 1, until the eight first-type detection zones are traversed respectively; the threshold value is selected as 15000 (range: 0-84420), when the number of pixel points in a first-type detection zone is lower than the threshold value, it can be judged that there is no cover, and the putText() function is used to mark it as red 'Empty'.
[0047] (82) In Figure G, the number of white pixel points in the eight second-type detection zones is counted. When the cover is completely closed, the number of white pixel points is the largest, and the value is the area of the elliptical region; when the opening angle of the cover is greater than or equal to 90°, the number of white pixel points is the smallest, and the value is 0. The arccos() function is selected to fit the opening angle of the cover, the ratio of the number of detected white pixel points to the area value of the elliptical region (0-1) is calculated first, and then the ratio is input into the arccos() function to calculate the opening angle of the cover (0°-90°). The calculated opening angle is marked below the cover, and the elliptical region is marked as green.
[0048] The embodiment of the present application also provides a storage medium, wherein the storage medium stores a computer program, and the computer program is set to execute any of the above-mentioned methods when running.
[0049] The embodiment of the present application also provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor is set to run the computer program to execute any of the above-mentioned methods.
Claims
1. A method for detecting the opening angle of an OPENCV reagent cover, characterized in that, It comprises the following steps: (1) take a picture of the well plate area before each injection to obtain image A; (2) pre-process the image to obtain image B in the effective range; specifically, read the coordinates of the four corners of the image, calculate the width and height of the image according to the coordinates of the four corners, define the effective area of the rectangle with the coordinates of the top-left corner and the width and height of the image, crop the effective area to obtain the image B in the effective range; (3) perform grayscale processing on the image using OPENCV to obtain image C; Specifically, the cvtColor method of the OPENCV image processing technology can be used to obtain the grayscale transformed image C from image B; (4) perform binaryzation processing on the image using OPENCV to obtain image D; specifically, first select an appropriate binaryzation threshold, set the pixel values of all pixel points in the grayscale image C that are higher than the threshold to 255, set the pixel values of all pixel points that are lower than the binaryzation threshold to 0, and use the threshold method of the OPENCV image processing technology to obtain the binaryzation image D; (5) perform mathematical morphology processing on the image to obtain image E; specifically, first perform dilation operation on image D, then perform erosion operation, and finally use the erode method of the OPENCV image processing technology to obtain the reagent cover contour image E; (6) design an elliptical detection area to obtain image G; comprising the following steps: (61) read the coordinates of the center points and the lengths of the major and minor axes of the eight positions of image E, and use the ellipse method of the OPENCV image processing technology to draw ellipses at the eight positions respectively, and the pixel values of the drawn elliptical regions are 0, which appear as black; (62) use the clone method of the OPENCV image processing technology to clone image E to obtain image F, and use the subtract() method of the OPENCV image processing technology to read the elliptical regions of image E and image F to obtain image G; (7) select the detection area; comprising the following steps: (71) divide image A into two parts horizontally and four parts vertically according to the horizontal coordinates, and the coordinates of each position can be obtained, and the selected eight detection areas for judging whether there is a cover are named as a type of detection area; (72) mark the positions of the eight elliptical graphs in image G according to the a type of detection area; (73) replace the elliptical detection area with the circumscribed rectangle of the ellipse, and name the eight circumscribed rectangle detection areas as a type of detection area; (8) judge the state of the reagent cover; comprising the following steps: (81) traverse the number of white pixel points in each a type of detection area in image E, that is, compare the pixel values of each pixel point, when the pixel value is 255, the number of pixel points in the region is increased by 1, until the eight a type of detection areas are traversed; select a threshold of 15000, when the number of pixel points in a certain a type of detection area is lower than the threshold range, it can be judged that there is no cover, and the putText() function is used to mark it as red 'Empty'; (82) In the figure G, the number of white pixel points in the eight secondary detection areas is counted, the ratio of the number of detected white pixel points to the area value of the elliptical area is calculated, then the ratio is transmitted into the arccos() function, the opening and closing angle of the cover is calculated, and the calculated opening and closing angle is marked below the cover, and the ellipse is marked green.
2. A storage medium having stored therein a computer program, wherein, The computer program is arranged to perform the method of claim 1 when run. 3.An electronic device comprising a memory and a processor, the memory having stored therein a computer program, the processor being arranged to run the computer program to perform the method of claim 1.
Citation Information
Patent Citations
Automatic detection method and device for surface defects of brake pad
CN110473201A
Scanning electron microscope image pore recognition method, terminal equipment and storage medium
CN112084884A
Irregular excessive glue opening detection method, device and equipment and storage medium
CN113379723A