Background
Gel-ink pens (Roller ball pens), or gel-ink ball-point pens, are a popular writing instrument in the world today. The pen can be divided into different types of gel-ink pens according to pen point type, ink color, structure and the like. The gel pen has the advantages of a fountain pen and an oil ball pen, is comfortable in writing hand feeling, low in ink viscosity, and added with easily-lubricated substances, and the viscosity of a writing medium is between that of water and oil, so that the gel pen is smoother than the common oil ball pen, and is an upgrading and updating product of the oil ball pen.
In the production of the gel ink pen, tail oil injection is one of necessary procedures, and whether the length of the tail oil is qualified or not is directly related to the use safety of the pen core. If the injection amount of the tail oil is too large or too small, the ink may be leaked in the subsequent centrifugation process, and the use of the ink by users is also damaged.
At present, in the production process of leading in the gel ink pen tail oil, various instruments, devices and methods are generally adopted, such as an inductor or a laser scanner, or the length of the gel ink pen tail oil is detected in a manual detection mode, so that defective products are screened out. However, the manual screening mode has large workload, low working efficiency and low accuracy, and the detection speed is difficult to meet the production requirement. In addition, the existing detection mode has the problems of fuzzy judgment qualified standard, inaccurate detection caused by observation angle, definition and magnification, low accuracy and efficiency caused by artificial uncontrollable factors, and the like.
Disclosure of Invention
The invention aims to provide a method and a system for automatically detecting the length of the refill tail oil, so that the detection accuracy and the detection efficiency can be obviously improved.
The purpose of the invention is realized as follows: a method for automatically detecting the length of a refill tail oil at least comprises the following steps:
s1, fixing the image acquisition device and the light source position in sequence;
s2, acquiring picture information, wherein when a trigger signal of the pen core transmission device is transmitted to the image acquisition device, the image acquisition device shoots pictures at the same time, and the shot picture information is transmitted to an industrial personal computer through a data transmission line;
s3, processing picture information, firstly, carrying out binarization processing on a picture through a gray scale image processing system, then framing out the whole tail oil part, checking the gray scale value of the tail oil part at the moment, setting the gray scale value range to be near the gray scale value of the tail oil part, marking the tail oil in the gray scale value range by green, calculating the length through a corresponding program, and displaying the length on a display, wherein the unit is a pixel;
and S4, a result output step, namely setting a standard tail oil length range by referring to the sample pen core, outputting a logic value '1' when the length is within a valid range, outputting a logic value '0' when the length is not within the range, outputting an 'invalid' value when no image is detected, and repeating the steps.
Further, the step S4 includes: and (4) transmitting the processed result to a pen core conveying device, reserving the pen core with the output logic result of '1', and rejecting the pen core with the output logic result of '0'.
Further, the shooting range of the image acquisition device covers all the detected pen cores at the detection position.
Furthermore, the light source irradiates the pen core from the lower part of the pen core, is 10-25 cm away from the pen core, and forms an included angle of 30-45 degrees with the pen core.
Further, the shooting frequency of the image acquisition device is consistent with the transmission frequency of the pen core transmission device.
Further, the optimal gray scale value range in the step S3 is 180 to 255.
In order to better realize the detection method, the invention provides an automatic detection system for the length of the tail oil of the pen core, which comprises a data transmission line, a light source, an industrial personal computer, an image acquisition device, a bracket and a pen core transmission device for transmitting the detected pen core, wherein the pen core transmission device is in signal connection with the image acquisition device and starts the shooting action of the image acquisition device while the pen core transmission device generates a transmission trigger signal, the image acquisition device is arranged as a gray image acquisition device and comprises a CCD camera and a lens, the image acquisition device is arranged on the bracket, the height of the bracket can be randomly adjusted and is opposite to the detected pen core, a data transmission port of the image acquisition device is in signal connection with the industrial personal computer through the data transmission line, the light source is arranged to uniformly radiate a strip-shaped light source and irradiate towards the detected pen core, the industrial personal computer is provided with a processing system for processing the picture information gray level image transmitted by the image acquisition device.
The invention has the beneficial effects that: the length detection of the tail oil of the refill can be carried out dynamically, and the automatic detection device has the advantages of light instrument, convenience in use, simplicity in operation, convenience in installation, accuracy and objectivity in data and capability of automatically storing a detection result; the labor intensity of inspection workers is reduced, and the detection efficiency is improved.
Detailed Description
The invention further discloses a method for automatically detecting the length of tail oil of a pen core by combining the accompanying drawings 1-3 and a specific embodiment.
As shown in figure 2, the detection device related to the method comprises a data transmission line 1, a light source 2, an industrial personal computer 3, an image acquisition device 4, a bracket 5 and a pen core transmission device 6 for transmitting a detected pen core 7.
The pen core transmission device (conveyor belt) 6 is in signal connection with the image acquisition device 4, and the pen core transmission device 6 generates a transmission trigger signal and simultaneously starts the shooting action of the image acquisition device 4, so that the shooting efficiency is accelerated.
Image acquisition device 4 sets up to grey level image acquisition device, including CCD camera and camera lens, image acquisition device 4 is equipped with the camera lens that focal length is 16mm, also can set up the camera lens that focal length is greater than 16mm, image acquisition device 4 installs on support 5, support 5 highly can adjust wantonly, set up anchor clamps (anchor clamps bore size can be adjusted) on support 5 in order to clip image acquisition device 4, and just to being detected the refill, image acquisition device 4's data transmission port passes through data transmission line 1 and industrial computer 3 signal connection.
The data transmission line 1 is provided with a conventional data interface and a trigger device interface, the data interface is connected with the industrial personal computer 3, and the trigger device interface is connected with an external trigger signal.
The light source 2 is set to be a uniform radiation strip-shaped light source and irradiates towards the refill to be detected, the length of the uniform radiation strip-shaped light source is about 8cm, the uniform radiation strip-shaped light source can emit visible light wave band parallel light, the brightness of the uniform radiation strip-shaped light source is controlled through the light source controller, the light source 2 can generate light with strong brightness, and the light intensity is uniform within a certain horizontal range.
The industrial personal computer 3 is provided with a processing system for processing the image information gray level image transmitted by the image acquisition device 4, mainly written by an open source algorithm OpenCV, and also conventionally provided with an image acquisition device connection interface, a USB interface, a liquid crystal display screen, a mouse and a keyboard.
As shown in fig. 1, the method at least comprises the following steps:
s1, fixing the image acquisition device 4 and the light source 2, firstly fixing the image acquisition device 4, adjusting the size of a clamp of the bracket 5 to enable the image acquisition device 4 to be vertically fixed on the bracket 5, enabling the lens of the image acquisition device 4 to be vertically downward to enable the height of the image acquisition device 4 to be less than 20cm, and simultaneously shooting at least four pen cores 7, adjusting the height of the image acquisition device 4 and adjusting the focal length of the image acquisition device 4 by vertically moving the clamp of the bracket 5 according to the placing positions of the pen cores 7 and the distance between the pen cores 7 to enable the image acquisition device 4 to simultaneously shoot the tail oil part at the tail end of the pen core 7 to be detected, and clearly displaying the tail oil part on a liquid crystal display; then, the operation step of fixing the light source 2 is carried out, the height of the image acquisition device 4 and the position of the detected pen core 7 are kept unchanged, the light source 2 is used for irradiating the tail end of the pen core 7, the gray scale displayed on a display screen by a tail oil part and a non-tail oil part is differentiated, the brightness of the tail oil part is brighter than that of the non-tail oil part, the height and the angle of the light source 2 are adjusted, the pen core is generally irradiated by the light source 2 from the lower part of the pen core 7, the distance between the light source 2 and the pen core 7 is about 10-25 cm, and an included angle of 30-45 degrees is formed between the light source 2 and the pen core 7;
s2, acquiring picture information, wherein when a trigger signal of the pen core transmission device 6 is transmitted to the image acquisition device 4, the image acquisition device 4 shoots a picture, and the shot picture information is transmitted to the industrial personal computer 3 through the data transmission line 1 (when the trigger signal is transmitted, a new pen core 7 sample exists, and the image acquisition device 4 shoots the picture to complete signal acquisition); in the step, the shooting mode of the image acquisition device 4 is selected as external trigger, an external trigger signal interface of the image acquisition device 4 is connected with an external trigger signal interface on the pen core transmission device through a data line, at the moment, when the image acquisition device 4 receives a trigger signal, the image acquisition device 4 automatically shoots a picture to complete image acquisition, the shooting frequency of the image acquisition device 4 is basically the same as the transmission frequency of the pen core transmission device, but in actual operation, the shooting delay time is several milliseconds;
s3, processing picture information, namely firstly, carrying out binarization processing on a picture through a gray level image processing system, carrying out binarization processing on the acquired picture by using a binarization function threshold of OpenCV, then framing out the whole tail oil part, checking the gray level value of the tail oil part at the moment, setting the gray level value range to be near the gray level value of the tail oil part, marking the tail oil in the range by green, calculating the length through a corresponding program, and displaying the length on a display, wherein the unit is a pixel; measuring the gray value for multiple times, then averaging to obtain the optimal gray value range, wherein the optimal gray value range is 180-255 generally, the boundary between the two parts can be well displayed, and the length of the two parts can be measured more effectively;
s4, a result output step, namely measuring the sample pen core 7 by the same method to obtain the length of tail oil of the sample pen core 7, wherein the length is generally 25mm, the error is within 0.5mm, then converting an actual length unit (mm) into a pixel value, when the best effect is achieved by measurement, the conversion relation between the resolution, the pixel value and the actual length is 1mm and approximately equal to 27 pixel values, finally setting the length range to be 25mm +/-0.5 mm, comparing the measured length in the gray value range with the set range, marking the measured length in the gray value range as green, marking the measured length in the gray value range as red, and marking the measured length out of the gray value range as red, and marking the measured length in the logic output as 0; setting a standard tail oil length range according to the sample pen core 7, outputting a logic value '1' when the length is within an effective range, outputting a logic value '0' when the length is not within the range, outputting an 'invalid' value when no image is detected, and repeating the steps; then the processed result is transmitted to a pen core transmission device 6, the pen core with the output logic result of 1 is reserved, and the pen core 7 with the output logic result of 0 is removed.
In step S3, after the image is binarized, the gray value of the pixel point on the image is between 0 and 255. Such images typically exhibit a distinct black and white effect (as shown in fig. 3), with 0 representing the lowest brightness and the tail black being displayed and 255 representing the brightest brightness and being displayed as white. By changing the height and the angle of the light source, any pixel point with the pixel value within the range can be displayed theoretically to form images with different gray levels. On the basis of the principle, a gray value difference detection method is adopted.
The principle of gray value difference detection is as follows:
1) selecting an area of interest (ROI), irradiating a tail oil part and a non-tail oil part at the tail end of the pen core 7 according to the light source 2 to enable the brightness of the tail oil part and the non-tail oil part to be different, firstly selecting a pen core 7 to frame the whole tail oil part, and adjusting the size of a frame, wherein the interval between the pen cores 7 is fixed in the production process, the tail parts of the pen cores 7 are all on the same horizontal line, and then adjusting the horizontal distance between the frame and the frame to enable the ROI of four pen cores 7 to be selected by four frames at the same time to finish signal acquisition. The width of the selected ROI is narrower than that of the tail oil;
2) calculating a gray value, after selecting an interested region, performing binarization processing on the image, and then calculating the gray value of a tail oil part in the region, wherein the gray value of the tail oil part is larger than that of a non-tail oil part because the tail oil part is brighter than the non-tail oil part and is closer to white;
3) calculating the length of the tail oil, setting the gray value range including the gray values of all tail oil gray pixel points according to the calculated gray value, marking the gray value with green, calculating the area of the marked part, dividing the area by the width of the selected ROI to obtain the length of the tail oil, wherein the unit is pixel, finally according to the conversion formula of the pixel and the actual length,
the actual length is calculated.
While the preferred embodiments of the present invention have been described, those skilled in the art will appreciate that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined by the appended claims.