CN108545265A - A kind of tablet capsule counting device and its method based on machine vision - Google Patents

A kind of tablet capsule counting device and its method based on machine vision Download PDF

Info

Publication number
CN108545265A
CN108545265A CN201810636247.0A CN201810636247A CN108545265A CN 108545265 A CN108545265 A CN 108545265A CN 201810636247 A CN201810636247 A CN 201810636247A CN 108545265 A CN108545265 A CN 108545265A
Authority
CN
China
Prior art keywords
image
tablet
capsules
bulk material
ccd camera
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810636247.0A
Other languages
Chinese (zh)
Inventor
方波
李东升
胡佳成
陈爱军
王璇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Jiliang University
Original Assignee
China Jiliang University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Jiliang University filed Critical China Jiliang University
Priority to CN201810636247.0A priority Critical patent/CN108545265A/en
Publication of CN108545265A publication Critical patent/CN108545265A/en
Pending legal-status Critical Current

Links

Classifications

    • BPERFORMING OPERATIONS; TRANSPORTING
    • B65CONVEYING; PACKING; STORING; HANDLING THIN OR FILAMENTARY MATERIAL
    • B65BMACHINES, APPARATUS OR DEVICES FOR, OR METHODS OF, PACKAGING ARTICLES OR MATERIALS; UNPACKING
    • B65B57/00Automatic control, checking, warning, or safety devices
    • B65B57/20Applications of counting devices for controlling the feed of articles

Landscapes

  • Engineering & Computer Science (AREA)
  • Mechanical Engineering (AREA)
  • Image Processing (AREA)

Abstract

本发明公开了一种基于机器视觉的药片胶囊计数装置及其方法,包括CCD相机机构;本发明采用可上下调节高度位置和可前后调节水平位置的CCD相机机构,通过倾斜度调节机构对散料板的倾斜角度的调节功能,又通过振动机构对散料板的振动作用,使得若干个药片胶囊排列容纳在W型沟槽的槽底中并形成一排排队列状的药片胶囊队列,大大提高了采集得到药片胶囊的真彩色图像的质量;采用MATLAB工具,通过图像处理方法对药片胶囊的真彩色图像进行图像处理,并依据图像处理结果对药片胶囊进行精确数目计数,大大提高了药片胶囊计数的精确性和工作效率;并且该装置整体设计合理,结构紧凑,充分利用了有限的平面与空间位置,成本较低,适合推广应用。

The invention discloses a tablet and capsule counting device and method based on machine vision, including a CCD camera mechanism; the invention adopts a CCD camera mechanism that can adjust the height position up and down and the horizontal position back and forth, and adjust the bulk material through the gradient adjustment mechanism. The adjustment function of the inclination angle of the plate, and the vibration effect of the vibration mechanism on the bulk material plate, make a number of tablet capsules arranged and accommodated in the bottom of the W-shaped groove and form a row of tablet capsules, which greatly improves To improve the quality of the collected true-color images of tablets and capsules; use MATLAB tools to process the images of true-color images of tablets and capsules through image processing methods, and count the number of tablets and capsules accurately according to the image processing results, which greatly improves the count of tablets and capsules The accuracy and work efficiency; and the overall design of the device is reasonable, compact, make full use of the limited plane and space position, low cost, suitable for popularization and application.

Description

一种基于机器视觉的药片胶囊计数装置及其方法A device and method for counting tablets and capsules based on machine vision

技术领域technical field

本发明涉及计数装置,尤其涉及一种基于机器视觉的药片胶囊计数装置及其方法。The invention relates to a counting device, in particular to a machine vision-based tablet and capsule counting device and method thereof.

背景技术Background technique

针对药业生产厂家在药片胶囊包装过程中,需要人工拿胶囊铲铲取药片胶囊并对铲取的药片胶囊进行人工计数数目,再完成药片胶囊的装盒包装,既使得计数不精确,又大大增加了工人劳动强度,大大降低了工作效率不高。Aiming at the pharmaceutical manufacturers, in the process of packaging tablets and capsules, it is necessary to manually pick up the tablets and capsules with a capsule shovel and manually count the number of the scooped tablets and capsules, and then complete the boxing and packaging of the tablets and capsules, which makes the counting inaccurate and greatly Increased labor intensity of workers, greatly reducing work efficiency is not high.

针对药业应用的医院、药房等地方,医务人员根据要求,需将各种各样的药品的药片胶囊重新按照一定的数量,进行分类并重新封装成小包装,由于药品种类较多且医务人员极其有限,如果将药片胶囊一片片、一粒粒的倒出来人工数数目,再进行分类,不仅使得医务人员工作量巨大,工作效率极低,而且人工数药片胶囊的方式极其容易数错数目,给医院、药房或者购买药片胶囊的使用者带来不必要的损失。For hospitals, pharmacies and other places where the pharmaceutical industry is used, medical personnel need to reclassify and repackage the tablets and capsules of various drugs according to a certain number according to requirements. Due to the large variety of drugs and the medical personnel Extremely limited, if the tablets and capsules are poured out one by one and manually counted, and then classified, not only will the medical staff have a huge workload and extremely low work efficiency, but also the method of manually counting the tablets and capsules is extremely easy to count the wrong number, Bring unnecessary losses to hospitals, pharmacies or users who buy tablet capsules.

发明内容Contents of the invention

本发明解决的技术问题是,克服现有技术的缺陷,提供一种采用可上下调节高度位置和可前后调节水平位置的CCD相机机构采集药片胶囊的真彩色图像的基于机器视觉的药片胶囊计数装置。The technical problem solved by the present invention is to overcome the defects of the prior art and provide a machine vision-based tablet capsule counting device that adopts a CCD camera mechanism that can adjust the height position up and down and the horizontal position can be adjusted back and forth to collect the true color images of the tablet capsules .

为了解决上述技术问题,本发明通过下述技术方案得以解决:In order to solve the above technical problems, the present invention is solved through the following technical solutions:

一种基于机器视觉的药片胶囊计数装置,包括机箱、固定设在机箱中并用于容纳药片胶囊的散料机构、固定设在机箱上方的CCD相机机构、与CCD相机机构连接的上位机模块、与上位机模块连接的显示屏,机箱顶部设有与上方的CCD相机机构正对的窗口,散料机构包括通过倾斜度调节机构可倾斜的固定设在窗口下面的散料板,散料板设有若干个W型沟槽,若干个药片胶囊排列容纳在W型沟槽的槽底中并形成一排排队列状规则排列的药片胶囊队列;CCD相机机构包括可上下调节高度位置或可前后调节水平位置的工业CCD相机,工业CCD相机固定设在机箱上方并与下方的窗口正对;通过工业CCD相机对W型沟槽的槽底中形成的一排排队列状规则排列的药片胶囊队列进行摄像并得到原始的真彩色图像,工业CCD相机再将采集得到的原始的真彩色图像传输给上位机模块,上位机模块采用MATLAB工具并通过图像处理方法对原始的真彩色图像进行图像处理,依据图像处理结果对原始的真彩色图像中的若干个药片胶囊进行统计计数得到W型沟槽的槽底中的药片胶囊的个数,药片胶囊的个数显示在显示屏上。其中,散料板的倾斜状态为前低后高,散料板的前侧固定设在机箱中,散料板后侧通过倾斜度调节机构带动上升或下降;上位机模块设在上位机中,显示屏可安装在机箱上,也可安装在上位机上;采用可上下调节高度位置和可前后调节水平位置的CCD相机机构的组合结构设置,通过CCD相机机构的位置调节功能以及倾斜度调节机构对散料板的倾斜角度的调节功能,又通过散料机构使得若干个药片胶囊排列容纳在W型沟槽的槽底中并形成一排排队列状的药片胶囊队列,大大提高了采集得到药片胶囊的真彩色图像的质量;采用MATLAB工具,通过图像处理方法对药片胶囊的真彩色图像进行图像处理,并依据图像处理结果对药片胶囊进行精确数目计数,大大提高了药片胶囊计数的精确性和工作效率;并且该装置整体设计合理,结构紧凑,充分利用了有限的平面与空间位置,并且成本较低。A tablet and capsule counting device based on machine vision, comprising a chassis, a bulk material mechanism fixed in the chassis and used to hold tablets and capsules, a CCD camera mechanism fixed above the chassis, a host computer module connected to the CCD camera mechanism, and The display screen connected to the upper computer module, the top of the chassis is provided with a window facing the upper CCD camera mechanism, the bulk material mechanism includes a bulk material plate that can be tilted and fixed under the window through an inclination adjustment mechanism, and the bulk material plate is equipped with Several W-shaped grooves, several tablets and capsules are arranged and accommodated in the bottom of the W-shaped grooves to form a row of regularly arranged rows of tablets and capsules; the CCD camera mechanism includes adjustable height positions up and down or front and rear adjustment levels The industrial CCD camera at the position, the industrial CCD camera is fixed on the top of the chassis and is directly facing the window below; the row of regularly arranged tablet capsules formed in the bottom of the W-shaped groove is photographed by the industrial CCD camera And get the original true-color image, the industrial CCD camera then transmits the collected original true-color image to the host computer module, the host computer module uses MATLAB tools to process the original true-color image through image processing methods, according to the image Processing Results Count the number of tablets and capsules in the original true-color image to obtain the number of tablets and capsules in the bottom of the W-shaped groove, and the number of tablets and capsules is displayed on the display screen. Among them, the inclination state of the bulk material plate is low at the front and high at the rear, the front side of the bulk material plate is fixed in the chassis, and the rear side of the bulk material plate is driven up or down by the inclination adjustment mechanism; the upper computer module is set in the upper computer, The display screen can be installed on the chassis or on the upper computer; it adopts the combined structure setting of the CCD camera mechanism that can adjust the height position up and down and the horizontal position can be adjusted forward and backward. Through the position adjustment function of the CCD camera mechanism and the tilt adjustment mechanism The adjustment function of the inclination angle of the bulk material plate, and through the bulk material mechanism, several tablet capsules are arranged and accommodated in the bottom of the W-shaped groove to form a row of tablet capsule queues, which greatly improves the collection of tablet capsules. The quality of the true color image; using MATLAB tools, the image processing method is used to image the true color image of the tablet and capsule, and the accurate number of the tablet and capsule is counted according to the image processing result, which greatly improves the accuracy and work of the tablet and capsule count. efficiency; and the overall design of the device is reasonable, the structure is compact, the limited plane and space are fully utilized, and the cost is low.

作为优选,倾斜度调节机构对散料板与水平面之间的倾斜夹角的角度调节范围为15-30度。当向散料板放入若干个药片胶囊过程中,15-30度倾斜状态的散料板使得药片胶囊能在自重作用与惯性作用的综合作用下自动顺沿散料板的倾斜壁面滑入W型沟槽的槽底中,既避免了药片胶囊之间的堆叠,也减少了药片胶囊之间的粘连结点数,使得减轻了后续通过图像处理方法对药片胶囊的计数难度,又提高了工作效率,并能保证后续工业CCD相机摄像取得的原始的真彩色图像中的药片胶囊数目的精确性,从而为最终通过图像处理方法对原始的真彩色图像的处理并计数得出药片胶囊的数目的精确性提供保证;若该倾斜夹角度数低于15-30度,则因为散料板的倾斜壁面的斜率不够高,导致药片胶囊难以在自重作用与惯性作用的综合作用下自动顺沿散料板的倾斜壁面滑入W型沟槽的槽底中,使得难以实现将待计数的若干个药片胶囊准确且有效的送入散料板的W型沟槽的槽底中,从而降低工作效率,并影响工业CCD相机摄像取得的原始的真彩色图像中的药片胶囊数目的精确性;若该倾斜夹角度数高于15-30度,可能导致滑入W型沟槽的槽底中的药片胶囊再次掉出W型沟槽的槽底,使得难以实现将待计数的若干个药片胶囊准确且有效的送入散料板的W型沟槽的槽底中,从而降低工作效率,并影响后续工业CCD相机摄像取得的原始的真彩色图像中的药片胶囊数目的精确性。Preferably, the angle adjustment range of the inclination adjustment mechanism for the inclination angle between the bulk material plate and the horizontal plane is 15-30 degrees. When several tablets and capsules are put into the bulk material plate, the bulk material plate in a 15-30 degree inclined state enables the tablets and capsules to slide automatically along the inclined wall of the bulk material plate into the W In the groove bottom of the type groove, it not only avoids the stacking of tablets and capsules, but also reduces the number of bonding points between tablets and capsules, which reduces the difficulty of subsequent counting of tablets and capsules through image processing methods and improves work efficiency. , and can ensure the accuracy of the number of tablets and capsules in the original true-color image captured by the follow-up industrial CCD camera, so that the accuracy of the number of tablets and capsules can be obtained by processing and counting the original true-color image through the image processing method If the included angle of inclination is less than 15-30 degrees, the slope of the inclined wall of the bulk material plate is not high enough, making it difficult for the tablet capsule to automatically follow the bulk material plate under the combined action of its own weight and inertia The inclined wall surface slides into the groove bottom of the W-shaped groove, making it difficult to accurately and effectively send several tablet capsules to be counted into the groove bottom of the W-shaped groove of the bulk material plate, thereby reducing work efficiency and Affects the accuracy of the number of tablets and capsules in the original true-color image captured by the industrial CCD camera; if the angle of inclination is higher than 15-30 degrees, it may cause the tablets and capsules that slide into the bottom of the W-shaped groove to reappear. Falling out of the bottom of the W-shaped groove makes it difficult to accurately and effectively send several tablet capsules to be counted into the bottom of the W-shaped groove of the bulk material plate, thereby reducing work efficiency and affecting the subsequent industrial CCD The accuracy of the number of pills and capsules in the raw true-color image captured by the camera.

作为优选,倾斜度调节机构包括顶杆、可转动的固定设在顶杆底端并带动顶杆上下移动的丝杠,顶杆顶端固定设在散料板后侧的底部。外力旋动丝杠,丝杠同时带动顶杆向上或向下移动,向上或向下移动的顶杆同时带动散料板后侧上升或下降,从而散料板呈前低后高状态且散料板与水平面之间的倾斜夹角为15-30度,即,当散料板与水平面之间的夹角低于15-30度时,通过外力旋动丝杠同时带动顶杆向上移动并使得散料板后侧相对前侧上升至夹角达到15-30度为止;当散料板与水平面之间的夹角高于15-30度时,通过外力旋动丝杠同时带动顶杆向下移动并使得散料板后侧相对前侧下降至夹角达到15-30度为止。Preferably, the inclination adjustment mechanism includes a push rod, a rotatable lead screw fixed at the bottom of the push rod and driving the push rod to move up and down, and the top of the push rod is fixed at the bottom of the rear side of the bulk material plate. The screw is rotated by external force, and the screw drives the ejector rod to move up or down at the same time, and the ejector rod moving up or down simultaneously drives the rear side of the bulk material plate to rise or fall, so that the bulk material plate is in a state of low front and high rear and the bulk material The inclination angle between the plate and the horizontal plane is 15-30 degrees, that is, when the angle between the bulk material plate and the horizontal plane is lower than 15-30 degrees, the screw is rotated by external force to drive the ejector rod to move upwards and make the The rear side of the bulk material plate rises relative to the front side until the angle reaches 15-30 degrees; when the angle between the bulk material plate and the horizontal plane is higher than 15-30 degrees, the screw is driven downward by external force Move and make the rear side of the bulk plate drop relative to the front side until the angle reaches 15-30 degrees.

作为优选,还包括固定设在散料板两侧的各一个条形光源,两个相对设置的条形光源同时向散料板发射光并照亮W型沟槽的槽底中形成的一排排队列状规则排列的药片胶囊队列,提高了工业CCD相机对药片胶囊摄像采集得到的原始的真彩色图像的图像质量和摄像效率。Preferably, it also includes a bar-shaped light source fixed on both sides of the bulk material plate, and two opposite bar-shaped light sources simultaneously emit light to the bulk material plate and illuminate a row formed in the bottom of the W-shaped groove. The regularly arranged queue of tablets and capsules improves the image quality and imaging efficiency of the original true-color images collected by the industrial CCD camera for capturing the tablets and capsules.

作为优选,还包括对散料板进行振动作用的振动机构,振动机构包括振动轴、驱动振动轴产生振动作用的电机,振动轴顶端固定设在散料板底部的中心,电机固定设在振动轴底端。其中,电机被支撑在机箱中;由电机与振动轴组合形成的振动机构对倾斜状态的散料板进行振动作用,进一步使得药片胶囊能在自重作用与惯性作用的综合作用下自动顺沿散料板的倾斜壁面滑入W型沟槽的槽底中,进一步降低了药片胶囊之间发生堆叠的可能性,进一步降低了药片胶囊之间的粘连结点数增加的可能性,也进一步减轻了后续通过图像处理方法对药片胶囊的计数难度;若缺少振动机构对散料板的振动作用,则很容易发生有些药片胶囊附着在W型沟槽的槽壁上并与W型沟槽的槽底中的药片胶囊粘连在一起,使得出现至少三粒药片胶囊中的任意两粒发生粘连而发生三粒药片胶囊出现三个粘连结点数,使得后续图像处理过程中的图像分割需处理更多的结点,大大增加了后续通过图像处理方法对药片胶囊的计数难度,也使得通过图像分割之后进行药片胶囊的个数统计计数出现较大偏差或误差,从而导致计数不精确,也降低了处理效率;或者发生W型沟槽的槽底中的药片胶囊上面堆叠另外的药片胶囊,也大大增加了后续通过图像处理方法对药片胶囊的计数难度和计数偏差或误差。As preferably, it also includes a vibration mechanism for vibrating the bulk material plate. The vibration mechanism includes a vibration shaft and a motor that drives the vibration shaft to generate vibration. The top of the vibration shaft is fixed at the center of the bottom of the bulk material plate, and the motor is fixed on the vibration shaft. bottom end. Among them, the motor is supported in the chassis; the vibration mechanism formed by the combination of the motor and the vibration shaft vibrates the bulk material plate in the inclined state, further enabling the tablets and capsules to automatically follow the bulk material under the combined action of self-weight and inertia. The inclined wall of the plate slides into the groove bottom of the W-shaped groove, which further reduces the possibility of stacking between the tablet capsules, further reduces the possibility of increasing the number of adhesion points between the tablet capsules, and further reduces the possibility of subsequent passage. It is difficult for the image processing method to count the tablets and capsules; if there is no vibration mechanism to vibrate the bulk plate, it is easy for some tablets and capsules to be attached to the groove wall of the W-shaped groove and collide with the bottom of the W-shaped groove. The tablets and capsules stick together, so that any two of at least three tablets and capsules are stuck together, and there are three sticking points in three tablets and capsules, so that the image segmentation in the subsequent image processing process needs to deal with more nodes. It greatly increases the difficulty of subsequent counting of tablets and capsules through image processing methods, and also causes large deviations or errors in the statistical counting of tablets and capsules after image segmentation, resulting in inaccurate counts and reduced processing efficiency; or Stacking other tablet capsules on top of the tablet capsules in the groove bottom of the W-shaped groove also greatly increases the difficulty and counting deviation or error of subsequent tablet capsule counting by image processing methods.

作为优选,CCD相机机构还包括固定设在机箱后侧的支撑杆、可上下调节高度位置或可前后调节水平位置的固定设在支撑杆上的连接块、固定连接在连接块上并向窗口方向伸出的相机夹、通过螺纹孔可旋动的固定设在连接块与支撑杆之间的上下微调旋钮和前后微调旋钮,工业CCD相机通过紧固旋钮固定设在相机夹中;通过螺纹孔旋动上下微调旋钮,从而连接块沿支撑杆上下移动的同时带动相机夹及工业CCD相机上下移动;通过螺纹孔旋动前后微调旋钮,从而连接块沿支撑杆前后移动的同时带动相机夹及工业CCD相机前后移动。上下微调旋钮和前后微调旋钮的组合设置,实现了工业CCD相机的高度位置和前后位置的调节,使得能根据W型沟槽的槽底中形成的一排排队列状规则排列的药片胶囊队列与工业CCD相机分别在竖直方向和水平方向上的距离来调节工业CCD相机的摄像位置,从而使得工业CCD相机能摄像采集得到最高清晰度的原始的真彩色图像。支撑杆、连接块、相机夹的组合结构设置,提高了工业CCD相机上下调节高度位置、前后调节水平位置以及摄像工作过程中的牢靠性和平稳性。As preferably, the CCD camera mechanism also includes a support bar fixed on the rear side of the cabinet, a connecting block fixed on the support bar that can adjust the height position up and down or the horizontal position can be adjusted back and forth, fixedly connected on the connecting block and facing the direction of the window. The protruding camera clip, the upper and lower fine-tuning knobs and the front and rear fine-tuning knobs that are rotatably fixed between the connecting block and the support rod through the threaded hole, the industrial CCD camera is fixed in the camera clip through the fastening knob; Move the fine-tuning knob up and down, so that the connecting block moves up and down along the support rod, and at the same time drive the camera clip and industrial CCD camera to move up and down; turn the front and rear fine-tuning knobs through the threaded hole, so that the connecting block moves forward and backward along the supporting rod, and at the same time drive the camera clip and industrial CCD The camera moves back and forth. The combined setting of the upper and lower fine-tuning knobs and the front and rear fine-tuning knobs realizes the adjustment of the height position and the front and rear position of the industrial CCD camera, making it possible to form a row of regular rows of tablets and capsules in the bottom of the W-shaped groove. The vertical and horizontal distances of the industrial CCD camera are used to adjust the camera position of the industrial CCD camera, so that the industrial CCD camera can capture the original true-color image with the highest definition. The combined structural setting of the support rod, the connecting block, and the camera clip improves the reliability and stability of the industrial CCD camera in the vertical adjustment of the height position, the front and rear adjustment of the horizontal position, and the camera work process.

作为优选,散料板前后两侧固定设有各一个挡板,防止了药片胶囊滑落或掉出散料板外面。Preferably, one baffle plate is fixed on the front and rear sides of the bulk material plate, which prevents the tablet capsules from slipping or falling out of the bulk material plate.

作为优选,倾斜度调节机构还包括可转动的固定设在丝杠上并带动丝杠转动的手摇手柄或电动手柄。手摇手柄便于手动操作;电动手柄实现自动操作,节省了人工。Preferably, the inclination adjustment mechanism further includes a rotatable hand handle or electric handle fixed on the lead screw and driving the lead screw to rotate. The hand handle is convenient for manual operation; the electric handle realizes automatic operation and saves labor.

一种基于机器视觉的药片胶囊计数方法,包括如下步骤:A method for counting tablets and capsules based on machine vision, comprising the steps of:

步骤Ⅰ:先通过手摇手柄旋动丝杠,丝杠同时带动顶杆向上或向下移动,向上或向下移动的顶杆同时带动散料板后侧上升或下降,从而散料板呈前低后高状态且散料板与水平面之间的倾斜夹角为15-30度;再将待计数的若干个药片胶囊放入散料板中,然后启动电机,电机驱动振动轴对散料板产生振动作用,若干个药片胶囊在振动作用下滑入W型沟槽中直至每条W型沟槽的槽底中形成一排排队列状的药片胶囊队列;Step Ⅰ: Rotate the lead screw through the hand handle first, the lead screw drives the ejector rod to move up or down at the same time, and the ejector rod moving up or down simultaneously drives the rear side of the bulk material plate to rise or fall, so that the bulk material plate is forward Low back high state and the inclination angle between the bulk material plate and the horizontal plane is 15-30 degrees; then put several tablets and capsules to be counted into the bulk material plate, and then start the motor, the motor drives the vibration shaft to the bulk material plate A vibration effect is generated, and several tablet capsules slide into the W-shaped groove under the vibration effect until a row of tablet-capsule queues are formed in the groove bottom of each W-shaped groove;

步骤Ⅱ:然后同时打开两个相对设置的条形光源,两个相对设置的条形光源同时向散料板发射光并照亮W型沟槽的槽底中形成的一排排队列状的药片胶囊队列;Step Ⅱ: Then turn on two oppositely arranged bar-shaped light sources at the same time, and the two oppositely arranged bar-shaped light sources emit light to the bulk material plate at the same time and illuminate the rows of tablets formed in the bottom of the W-shaped groove capsule queue;

步骤Ⅲ:再启动工业CCD相机,通过工业CCD相机对照亮的一排排队列状的药片胶囊队列进行摄像并得到原始的真彩色图像,工业CCD相机再将采集得到的原始的真彩色图像传输给上位机模块,上位机模块采用MATLAB工具并通过图像处理方法对原始的真彩色图像进行图像处理,依据图像处理结果对原始的真彩色图像中的若干个药片胶囊进行统计计数得到W型沟槽的槽底中的药片胶囊的个数,药片胶囊的个数显示在显示屏上。Step Ⅲ: Restart the industrial CCD camera, use the industrial CCD camera to take pictures of the illuminated rows of pills and capsules and get the original true-color image, and then the industrial CCD camera will transmit the collected original true-color image For the host computer module, the host computer module uses MATLAB tools to process the original true-color image through image processing methods, and counts several tablets and capsules in the original true-color image according to the image processing results to obtain W-shaped grooves The number of tablets and capsules in the bottom of the tank is displayed on the display screen.

作为优选,步骤Ⅲ中的图像处理方法包括如下步骤:As preferably, the image processing method in step III includes the following steps:

步骤一:采用MATLAB工具读取原始的真彩色图像;Step 1: Use MATLAB tools to read the original true-color image;

步骤二:图像预处理:包括如下具体步骤:Step 2: Image preprocessing: including the following specific steps:

A、图像灰度化处理:依据原始的真彩色图像中每个像素点R、G、B的分量,以R、G、B为权重通过Gray(i,j)函数计算出每个像素点的灰度级,从而将原始的真彩色图像转化为灰度图像,其中,Gray(i,j)=0.299×R(i,j)+0.587×G(i,j)+0.114×B(i,j),Gray(i,j)为灰度图像在i,j处的灰度级,R(i,j)为原始的真彩色图像在i,j处的红亮度值,G(i,j)为原始的真彩色图像在i,j处的绿亮度值,B(i,j)为原始的真彩色图像在i,j处的蓝亮度值;A. Image grayscale processing: According to the components of R, G, and B of each pixel in the original true-color image, the weight of each pixel is calculated through the Gray(i,j) function with R, G, and B as weights. Grayscale, so as to convert the original true color image into a grayscale image, where Gray(i,j)=0.299×R(i,j)+0.587×G(i,j)+0.114×B(i, j), Gray(i,j) is the gray level of the grayscale image at i,j, R(i,j) is the red brightness value of the original true color image at i,j, G(i,j ) is the green brightness value of the original true color image at i, j, and B(i, j) is the blue brightness value of the original true color image at i, j;

B、图像滤波处理:采用中值滤波算法对经过步骤A处理得到的灰度图像进行中值滤波处理,得到去除噪声信息的灰度图像;B, image filtering processing: adopt median filtering algorithm to carry out median filtering processing to the grayscale image that obtains through step A processing, obtain the grayscale image that removes noise information;

C、图像二值化处理:采用二值化阈值分割法并通过f(x)函数对步骤B得到的去除噪声信息的灰度图像进行图像分割处理,将灰度图像中的每个像素点的灰度值逐一与最佳阈值T比较,若像素点的灰度值小于所述的最佳阈值T,则将该像素点的灰度值设置为黑色,并将各个灰度值为黑色的像素点形成的区域标记为背景;若像素点的灰度值不小于所述的最佳阈值T,则将该像素点的灰度值设置为白色,并将各个灰度值为白色的像素点形成的白色联通块标记为药片胶囊的图像;其中,T为最佳阈值;步骤C的图像二值化处理实质上是将灰度图像中每两个药片胶囊之间的图像粘连处的图像腐蚀掉,被腐蚀掉的图像粘连处与黑色背景融为一体,从而将两两粘连的药片胶囊的图像分割开,分割开的每个药片胶囊的图像形成一个白色联通块,保证了后续对经过步骤C处理之后的图像进行图像边缘检测和轮廓特征提取以及统计计数的图像处理效率和计数精确性;C, image binarization processing: adopt binarization threshold value segmentation method and carry out image segmentation processing to the gray scale image that removes noise information that step B obtains by f(x) function, the each pixel point in the gray scale image The grayscale value is compared with the optimal threshold T one by one, if the grayscale value of the pixel is less than the optimal threshold T, the grayscale value of the pixel is set to black, and the pixel with each grayscale value is black The area formed by the dots is marked as the background; if the gray value of the pixel is not less than the optimal threshold T, the gray value of the pixel is set to white, and the gray value of each pixel is white to form The white connected blocks marked as the image of the pill capsule; among them, T is the optimal threshold; the image binarization process in step C is to corrode the image of the image adhesion between every two tablet capsules in the grayscale image, and the image adhesion that is corroded is blended with the black background Integrate, so that the images of the two-adhesive tablet capsules are separated, and the images of each tablet capsule are separated to form a white connected block, which ensures the subsequent image edge detection and contour feature extraction of the image after step C processing. Image processing efficiency and counting accuracy for statistical counting;

步骤三:图像边缘检测和轮廓特征提取:采用Rober边缘检测算法对步骤C得到的灰度图像中的每个药片胶囊的图像进行图像边缘检测并提取每个药片胶囊的图像的边缘,得到包含每个药片胶囊的图像的轮廓特征的灰度图像;Step 3: Image edge detection and contour feature extraction: use the Rober edge detection algorithm to perform image edge detection on the image of each tablet capsule in the grayscale image obtained in step C and extract the edge of the image of each tablet capsule, and obtain the image containing each tablet capsule. A grayscale image of the contour features of an image of a tablet capsule;

步骤四:统计计数:通过MATLAB工具甄别黑色背景下的白色联通块并对输出白色联通块的区域的数量进行计数,从而统计得到白色联通块的个数,从而统计得到药片胶囊的个数。Step 4: Statistical counting: Use MATLAB tools to identify white connected blocks on a black background and count the number of areas where white connected blocks are output, so as to count the number of white connected blocks and obtain the number of tablets and capsules.

本发明由于采用了以上技术方案,具有显著的技术效果:采用可上下调节高度位置和可前后调节水平位置的CCD相机机构,通过倾斜度调节机构对散料板的倾斜角度的调节功能,又通过振动机构对散料板的振动作用,使得若干个药片胶囊排列容纳在W型沟槽的槽底中并形成一排排队列状的药片胶囊队列,大大提高了采集得到药片胶囊的真彩色图像的质量;采用MATLAB工具,通过图像处理方法对药片胶囊的真彩色图像进行图像处理,并依据图像处理结果对药片胶囊进行精确数目计数,大大提高了药片胶囊计数的精确性和工作效率;并且该装置整体设计合理,结构紧凑,充分利用了有限的平面与空间位置,成本较低,适合推广应用。Due to the adoption of the above technical scheme, the present invention has remarkable technical effects: it adopts a CCD camera mechanism that can adjust the height position up and down and the horizontal position can be adjusted back and forth, and the inclination angle adjustment function of the bulk material plate through the inclination adjustment mechanism. The vibrating action of the vibration mechanism on the bulk material plate makes several tablets and capsules arranged and accommodated in the bottom of the W-shaped groove to form a row of tablets and capsules, which greatly improves the accuracy of collecting and obtaining true-color images of tablets and capsules. quality; using MATLAB tools, image processing is performed on the true-color images of the tablets and capsules by means of image processing, and accurate number counting of the tablets and capsules is carried out according to the image processing results, which greatly improves the accuracy and work efficiency of the counting of the tablets and capsules; and the device The overall design is reasonable, the structure is compact, the limited plane and space are fully utilized, the cost is low, and it is suitable for popularization and application.

附图说明Description of drawings

图1为本发明的基于机器视觉的药片胶囊计数装置实施例的结构示意图。FIG. 1 is a schematic structural view of an embodiment of a machine vision-based tablet and capsule counting device of the present invention.

图2为本发明的待计数的若干个药片胶囊容纳在散料板的W型沟槽的槽底中并形成一排排队列状规则排列的药片胶囊队列实施例的局部结构示意图。Fig. 2 is a partial structural schematic diagram of an embodiment of the present invention in which several tablet capsules to be counted are accommodated in the bottom of the W-shaped groove of the bulk material plate and form a row of regularly arranged tablet capsule queues.

图3为本发明的振动机构、散料板、倾斜度调节机构之间装配实施例的结构示意图。Fig. 3 is a structural diagram of an embodiment of the assembly of the vibrating mechanism, the bulk plate, and the inclination adjusting mechanism of the present invention.

图4为本发明通过工业CCD相机对容纳在W型沟槽的槽底中并形成一排排队列状规则排列的药片胶囊队列进行摄像采集得到的原始的真彩色图像。Fig. 4 is the original true-color image captured by the present invention through an industrial CCD camera that is housed in the groove bottom of the W-shaped groove and forms a row of regularly arranged rows of tablet capsules.

图5为通过步骤二的A步骤对图4的原始的真彩色图像进行图像灰度化处理之后得到的灰度图像。FIG. 5 is a grayscale image obtained after performing image grayscale processing on the original true-color image in FIG. 4 through Step A of Step 2.

图6为通过步骤二的B步骤对图5的灰度图像进行图像滤波处理之后得到的灰度图像。FIG. 6 is a grayscale image obtained after performing image filtering on the grayscale image in FIG. 5 through Step B of Step 2.

图7为通过步骤二的C步骤对图6的灰度图像进行图像二值化处理之后得到的黑白色图像。FIG. 7 is a black-and-white image obtained after image binarization processing is performed on the grayscale image in FIG. 6 through Step C of Step 2.

图8为通过步骤三对图7的黑白色图像进行图像边缘检测和轮廓特征提取处理之后得到的黑白色图像。FIG. 8 is a black and white image obtained after performing image edge detection and contour feature extraction on the black and white image in FIG. 7 through step three.

具体实施方式Detailed ways

下面结合附图与实施例对本发明作进一步详细描述。The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments.

一种基于机器视觉的药片胶囊计数装置,如图1-3所示,包括机箱15、固定设在机箱15中并用于容纳药片胶囊16的散料机构、固定设在机箱15上方的CCD相机机构、与CCD相机机构连接的上位机模块1、与上位机模块1连接的显示屏2,机箱15顶部设有与上方的CCD相机机构正对的窗口150,散料机构包括通过倾斜度调节机构可倾斜的固定设在窗口150下面的散料板11,散料板11设有若干个W型沟槽110,若干个药片胶囊16排列容纳在W型沟槽110的槽底中并形成一排排队列状规则排列的药片胶囊16队列;CCD相机机构包括可上下调节高度位置或可前后调节水平位置的工业CCD相机9,工业CCD相机9固定设在机箱15上方并与下方的窗口150正对;通过工业CCD相机9对W型沟槽110的槽底中形成的一排排队列状规则排列的药片胶囊16队列进行摄像并得到原始的真彩色图像,工业CCD相机9再将采集得到的原始的真彩色图像传输给上位机模块1,上位机模块1采用MATLAB工具并通过图像处理方法对原始的真彩色图像进行图像处理,依据图像处理结果对原始的真彩色图像中的若干个药片胶囊16进行统计计数得到W型沟槽110的槽底中的药片胶囊16的个数,药片胶囊16的个数显示在显示屏2上。A tablet capsule counting device based on machine vision, as shown in Figures 1-3, includes a chassis 15, a bulk material mechanism fixed in the chassis 15 and used to accommodate tablet capsules 16, and a CCD camera mechanism fixed on the top of the chassis 15 1. The upper computer module 1 connected with the CCD camera mechanism, the display screen 2 connected with the upper computer module 1, the top of the casing 15 is provided with a window 150 facing the CCD camera mechanism above, and the bulk material mechanism includes a tilt adjustment mechanism. The bulk material plate 11 fixedly arranged under the window 150 is tilted. The bulk material plate 11 is provided with several W-shaped grooves 110, and several tablet capsules 16 are arranged and accommodated in the groove bottom of the W-shaped groove 110 and form a row. Tablets and capsules 16 are regularly arranged in rows; the CCD camera mechanism includes an industrial CCD camera 9 that can adjust the height position up and down or adjust the horizontal position forward and backward. The industrial CCD camera 9 is fixed on the top of the chassis 15 and faces the window 150 below; Through the industrial CCD camera 9, a row of regularly arranged tablet capsules 16 queues formed in the groove bottom of the W-shaped groove 110 are photographed and the original true-color image is obtained, and the industrial CCD camera 9 collects the original image The true color image is transmitted to the upper computer module 1, and the upper computer module 1 uses MATLAB tools to perform image processing on the original true color image through an image processing method, and according to the image processing result, several tablet capsules 16 in the original true color image are processed. Statistical counting obtains the number of tablet capsules 16 in the groove bottom of the W-shaped groove 110 , and the number of tablet capsules 16 is displayed on the display screen 2 .

本实施例中,倾斜度调节机构对散料板11与水平面之间的倾斜夹角的角度调节范围为15-30度。In this embodiment, the angle adjustment range of the inclination adjustment mechanism for the inclination angle between the bulk material plate 11 and the horizontal plane is 15-30 degrees.

本实施例中,倾斜度调节机构包括顶杆19、可转动的固定设在顶杆19底端并带动顶杆19上下移动的丝杠13,顶杆19顶端固定设在散料板11后侧的底部。In this embodiment, the inclination adjustment mechanism includes a push rod 19, a screw 13 that is rotatably fixed at the bottom of the push rod 19 and drives the push rod 19 to move up and down, and the top of the push rod 19 is fixed on the rear side of the bulk material plate 11 bottom of.

本实施例中,还包括固定设在散料板11两侧的各一个条形光源12,两个相对设置的条形光源12同时向散料板11发射光并照亮W型沟槽110的槽底中形成的一排排队列状规则排列的药片胶囊16队列。In this embodiment, it also includes a bar-shaped light source 12 fixedly arranged on both sides of the bulk material plate 11, and the two oppositely arranged bar-shaped light sources 12 simultaneously emit light to the bulk material plate 11 and illuminate the W-shaped groove 110. Tablet capsules 16 queues that are regularly arranged in a row form in the groove bottom.

本实施例中,还包括对散料板11进行振动作用的振动机构,振动机构包括振动轴17、驱动振动轴17产生振动作用的电机18,振动轴17顶端固定设在散料板11底部的中心,电机18固定设在振动轴17底端。In this embodiment, it also includes a vibrating mechanism for vibrating the bulk material plate 11. The vibrating mechanism includes a vibrating shaft 17, a motor 18 that drives the vibrating shaft 17 to vibrate, and the top of the vibrating shaft 17 is fixed on the bottom of the bulk material plate 11. In the center, the motor 18 is fixedly located at the bottom of the vibrating shaft 17 .

本实施例中,CCD相机机构还包括固定设在机箱15后侧的支撑杆3、可上下调节高度位置或可前后调节水平位置的固定设在支撑杆3上的连接块4、固定连接在连接块4上并向窗口150方向伸出的相机夹7、通过螺纹孔可旋动的固定设在连接块4与支撑杆3之间的上下微调旋钮5和前后微调旋钮6,工业CCD相机9通过紧固旋钮8固定设在相机夹7中;通过螺纹孔旋动上下微调旋钮5,从而连接块4沿支撑杆3上下移动的同时带动相机夹7及工业CCD相机9上下移动;通过螺纹孔旋动前后微调旋钮6,从而连接块4沿支撑杆3前后移动的同时带动相机夹7及工业CCD相机9前后移动。In this embodiment, the CCD camera mechanism also includes a support rod 3 fixedly arranged on the rear side of the cabinet 15, a connecting block 4 fixedly arranged on the support rod 3 which can adjust the height position up and down or the horizontal position can be adjusted forward and backward, and fixedly connected to the connecting block 4. On the block 4 and the camera clip 7 that stretches out towards the window 150 direction, the up and down fine-tuning knob 5 and the front and rear fine-tuning knob 6 that are rotatably fixed between the connecting block 4 and the support rod 3 through the threaded hole, the industrial CCD camera 9 passes through The fastening knob 8 is fixedly arranged in the camera clip 7; the fine-tuning knob 5 is rotated up and down through the threaded hole, so that the connecting block 4 moves up and down along the support rod 3 and drives the camera clip 7 and the industrial CCD camera 9 to move up and down; Move the fine-tuning knob 6 back and forth, so that the connecting block 4 moves back and forth along the support rod 3 and drives the camera clip 7 and the industrial CCD camera 9 to move back and forth.

本实施例中,散料板11前后两侧固定设有各一个挡板10。In this embodiment, one baffle plate 10 is fixed on the front and rear sides of the bulk material plate 11 .

本实施例中,倾斜度调节机构还包括可转动的固定设在丝杠13上并带动丝杠13转动的手摇手柄14,当然,也可将手摇手柄改为电动手柄,以实现自动摇动。In this embodiment, the inclination adjustment mechanism also includes a rotatable hand handle 14 that is fixed on the lead screw 13 and drives the lead screw 13 to rotate. Of course, the hand handle can also be changed into an electric handle to realize automatic shaking. .

一种基于机器视觉的药片胶囊计数方法,包括如下步骤:A method for counting tablets and capsules based on machine vision, comprising the steps of:

步骤Ⅰ:先通过手摇手柄14旋动丝杠13,丝杠13同时带动顶杆19向上或向下移动,向上或向下移动的顶杆19同时带动散料板11后侧上升或下降,从而散料板11呈前低后高状态且散料板11与水平面之间的倾斜夹角为15-30度;再将待计数的若干个药片胶囊16放入散料板11中,然后启动电机18,电机18驱动振动轴17对散料板11产生振动作用,若干个药片胶囊16在振动作用下滑入W型沟槽110中直至每条W型沟槽110的槽底中形成一排排队列状的药片胶囊16队列;Step Ⅰ: Rotate the lead screw 13 through the hand handle 14 first, and the lead screw 13 drives the ejector rod 19 to move up or down at the same time, and the ejector rod 19 moving up or down simultaneously drives the rear side of the bulk material plate 11 to rise or fall. Thus the bulk material plate 11 is in the state of low front and high rear and the inclination angle between the bulk material plate 11 and the horizontal plane is 15-30 degrees; then several tablet capsules 16 to be counted are put into the bulk material plate 11, and then start The motor 18, the motor 18 drives the vibrating shaft 17 to vibrate the bulk material plate 11, and several tablet capsules 16 slide into the W-shaped grooves 110 under the action of the vibration until a row is formed in the bottom of each W-shaped groove 110 16 rows of pill capsules in row shape;

步骤Ⅱ:然后同时打开两个相对设置的条形光源12,两个相对设置的条形光源12同时向散料板11发射光并照亮W型沟槽110的槽底中形成的一排排队列状的药片胶囊16队列;Step II: Then turn on two opposite bar-shaped light sources 12 at the same time, and the two oppositely arranged bar-shaped light sources 12 simultaneously emit light to the bulk material plate 11 and illuminate a row of queues formed in the bottom of the W-shaped groove 110 16 rows of pill capsules in row shape;

步骤Ⅲ:再启动工业CCD相机9,通过工业CCD相机9对照亮的一排排队列状的药片胶囊16队列进行摄像并得到原始的真彩色图像,如图4所示,工业CCD相机9再将采集得到的原始的真彩色图像传输给上位机模块1,上位机模块1采用MATLAB工具并通过图像处理方法对原始的真彩色图像进行图像处理,依据图像处理结果对原始的真彩色图像中的若干个药片胶囊16进行统计计数得到W型沟槽110的槽底中的药片胶囊16的个数,药片胶囊16的个数显示在显示屏2上。Step Ⅲ: Restart the industrial CCD camera 9, take pictures of the rows of pill capsules 16 queues illuminated by the industrial CCD camera 9 and obtain the original true-color image, as shown in Figure 4, the industrial CCD camera 9 again The collected original true-color image is transmitted to the upper computer module 1, and the upper computer module 1 uses MATLAB tools to perform image processing on the original true-color image through an image processing method, and performs image processing on the original true-color image according to the image processing result. Several tablet capsules 16 are statistically counted to obtain the number of tablet capsules 16 in the groove bottom of the W-shaped groove 110 , and the number of tablet capsules 16 is displayed on the display screen 2 .

本实施例中,步骤Ⅲ中的图像处理方法包括如下步骤:In this embodiment, the image processing method in step III includes the following steps:

步骤一:采用MATLAB工具读取原始的真彩色图像;Step 1: Use MATLAB tools to read the original true-color image;

步骤二:图像预处理:包括如下具体步骤:Step 2: Image preprocessing: including the following specific steps:

A、图像灰度化处理:依据原始的真彩色图像中每个像素点R、G、B的分量,以R、G、B为权重通过Gray(i,j)函数计算出每个像素点的灰度级,从而将原始的真彩色图像转化为灰度图像,如图5所示,其中,Gray(i,j)=0.299×R(i,j)+0.587×G(i,j)+0.114×B(i,j),Gray(i,j)为灰度图像在i,j处的灰度级,R(i,j)为原始的真彩色图像在i,j处的红亮度值,G(i,j)为原始的真彩色图像在i,j处的绿亮度值,B(i,j)为原始的真彩色图像在i,j处的蓝亮度值;A. Image grayscale processing: According to the components of R, G, and B of each pixel in the original true-color image, the weight of each pixel is calculated through the Gray(i,j) function with R, G, and B as weights. Grayscale, so as to convert the original true color image into a grayscale image, as shown in Figure 5, where Gray(i,j)=0.299×R(i,j)+0.587×G(i,j)+ 0.114×B(i,j), Gray(i,j) is the gray level of the grayscale image at i,j, R(i,j) is the red brightness value of the original true color image at i,j , G(i, j) is the green brightness value of the original true color image at i, j, B(i, j) is the blue brightness value of the original true color image at i, j;

B、图像滤波处理:采用中值滤波算法对经过步骤A处理得到的灰度图像进行中值滤波处理,得到去除噪声信息的灰度图像,如图6所示;B, image filter processing: adopt median filter algorithm to carry out median filter processing to the grayscale image that obtains through step A processing, obtain the grayscale image that removes noise information, as shown in Figure 6;

C、图像二值化处理:采用二值化阈值分割法并通过f(x)函数对步骤B得到的去除噪声信息的灰度图像进行图像分割处理,将灰度图像中的每个像素点的灰度值逐一与最佳阈值T比较,若像素点的灰度值小于所述的最佳阈值T,则将该像素点的灰度值设置为黑色,并将各个灰度值为黑色的像素点形成的区域标记为背景;若像素点的灰度值不小于所述的最佳阈值T,则将该像素点的灰度值设置为白色,并将各个灰度值为白色的像素点形成的白色联通块标记为药片胶囊16的图像;其中,T为最佳阈值;经过步骤C的图像二值化处理之后得到如图7所示的图像;C, image binarization processing: adopt binarization threshold value segmentation method and carry out image segmentation processing to the gray scale image that removes noise information that step B obtains by f(x) function, the each pixel point in the gray scale image The grayscale value is compared with the optimal threshold T one by one, if the grayscale value of the pixel is less than the optimal threshold T, then the grayscale value of the pixel is set to black, and the pixel with each grayscale value is black The area formed by the dots is marked as the background; if the gray value of the pixel is not less than the optimal threshold T, the gray value of the pixel is set to white, and the gray value of each pixel is white to form The white connected blocks marked as the image of the tablet capsule 16; where, T is optimal threshold; Obtain the image as shown in Figure 7 after the image binarization processing of step C;

步骤三:图像边缘检测和轮廓特征提取:采用Rober边缘检测算法对步骤C得到的灰度图像中的每个药片胶囊16的图像进行图像边缘检测并提取每个药片胶囊16的图像的边缘,得到包含每个药片胶囊16的图像的轮廓特征的黑白色图像,如图8所示;Step 3: image edge detection and contour feature extraction: use the Rober edge detection algorithm to perform image edge detection on the image of each tablet capsule 16 in the grayscale image obtained in step C and extract the edge of the image of each tablet capsule 16 to obtain A black and white image of the outline features of the image containing each tablet capsule 16, as shown in Figure 8;

步骤四:统计计数:通过MATLAB工具甄别黑色背景下的白色联通块并对输出白色联通块的区域的数量进行计数,从而统计得到白色联通块的个数,从而统计得到药片胶囊16的个数。Step 4: Statistical counting: use the MATLAB tool to identify the white Unicom blocks under the black background and count the number of areas where the white Unicom blocks are output, so as to obtain the number of white Unicom blocks and obtain the number of tablets and capsules 16.

总之,以上所述仅为本发明的较佳实施例,凡依本发明申请专利范围所作的均等变化与修饰,皆应属本发明专利的涵盖范围。In a word, the above descriptions are only preferred embodiments of the present invention, and all equivalent changes and modifications made according to the scope of the patent application of the present invention shall fall within the scope of the patent of the present invention.

Claims (10)

1.一种基于机器视觉的药片胶囊计数装置,其特征在于:包括机箱(15)、固定设在机箱(15)中并用于容纳药片胶囊(16)的散料机构、固定设在机箱(15)上方的CCD相机机构、与CCD相机机构连接的上位机模块(1)、与上位机模块(1)连接的显示屏(2),机箱(15)顶部设有与上方的CCD相机机构正对的窗口(150),散料机构包括1. A tablet capsule counting device based on machine vision, characterized in that: comprise a cabinet (15), be fixedly arranged in the cabinet (15) and be used to accommodate the bulk material mechanism of the tablet capsule (16), be fixedly arranged in the cabinet (15) ) above the CCD camera mechanism, the host computer module (1) connected with the CCD camera mechanism, the display screen (2) connected with the host computer module (1), and the top of the chassis (15) is equipped with a CCD camera mechanism facing the top The window (150), the bulk material mechanism includes 通过倾斜度调节机构可倾斜的固定设在窗口(150)下面的散料板(11),The bulk material plate (11) arranged below the window (150) can be tiltably fixed by the inclination adjustment mechanism, 散料板(11)设有若干个W型沟槽(110),若干个药片胶囊(16)排列容纳在W型沟槽(110)的槽底中并形成一排排队列状规则排列的药片胶囊(16)队列;CCD相机机构包括可上下调节高度位置或可前后调节水平位置的工业CCD相机(9),工业CCD相机(9)固定设在机箱(15)上方并与下方的窗口(150)正对;通过工业CCD相机(9)对W型沟槽(110)的槽底中形成的一排排队列状规则排列的药片胶囊(16)队列进行摄像并得到原始的真彩色图像,工业CCD相机(9)再将采集得到的原始的真彩色图像传输给上位机模块(1),上位机模块(1)采用MATLAB工具并通过图像处理方法对原始的真彩色图像进行图像处理,依据图像处理结果对原始的真彩色图像中的若干个药片胶囊(16)进行统计计数得到W型沟槽(110)的槽底中的药片胶囊(16)的个数,药片胶囊(16)的个数显示在显示屏(2)上。The bulk material plate (11) is provided with several W-shaped grooves (110), and several tablet capsules (16) are arranged and accommodated in the bottom of the W-shaped grooves (110) to form a row of regularly arranged tablets. The capsule (16) queue; the CCD camera mechanism includes an industrial CCD camera (9) that can adjust the height position up and down or can adjust the horizontal position forward and backward. ) is facing; take pictures of a row of tablet capsules (16) formed in the groove bottom of the W-shaped groove (110) by an industrial CCD camera (9) and obtain an original true-color image. CCD camera (9) transmits the original true-color image that gathers to host computer module (1) again, and upper computer module (1) adopts MATLAB instrument and carries out image processing to original true-color image by image processing method, according to image The processing result counts several tablet capsules (16) in the original true-color image and obtains the number of tablet capsules (16) in the groove bottom of the W-shaped groove (110), and the number of tablet capsules (16) is shown on the display (2). 2.根据权利要求1所述的一种基于机器视觉的药片胶囊计数装置,其特征在于:倾斜度调节机构对散料板(11)与水平面之间的倾斜夹角的角度调节范围为15-30度。2. A kind of tablet capsule counting device based on machine vision according to claim 1, characterized in that: the angle adjustment range of the inclination adjustment mechanism to the inclination angle between the bulk material plate (11) and the horizontal plane is 15- 30 degrees. 3.根据权利要求1或2所述的一种基于机器视觉的药片胶囊计数装置,其特征在于:倾斜度调节机构包括顶杆(19)、可转动的固定设在顶杆(19)底端并带动顶杆(19)上下移动的丝杠(13),顶杆(19)顶端固定设在散料板(11)后侧的底部。3. A kind of tablet capsule counting device based on machine vision according to claim 1 or 2, characterized in that: the inclination adjustment mechanism comprises a push rod (19), which is rotatably fixed at the bottom end of the push rod (19). And drive the leading screw (13) that push rod (19) moves up and down, the top of push rod (19) is fixedly located at the bottom of bulk plate (11) rear side. 4.根据权利要求3所述的一种基于机器视觉的药片胶囊计数装置,其特征在于:还包括固定设在散料板(11)两侧的各一个条形光源(12),两个相对设置的条形光源(12)同时向散料板(11)发射光并照亮W型沟槽(110)的槽底中形成的一排排队列状规则排列的药片胶囊(16)队列。4. A kind of tablet capsule counting device based on machine vision according to claim 3, characterized in that: it also includes a strip light source (12) fixedly arranged on both sides of the bulk material plate (11), two opposite The set strip light source (12) simultaneously emits light to the bulk material plate (11) and illuminates a row of regularly arranged tablet capsules (16) formed in the groove bottom of the W-shaped groove (110). 5.根据权利要求1或2或4所述的一种基于机器视觉的药片胶囊计数装置,其特征在于:还包括对散料板(11)进行振动作用的振动机构,振动机构包括振动轴(17)、驱动振动轴(17)产生振动作用的电机(18),振动轴(17)顶端固定设在散料板(11)底部的中心,电机(18)固定设在振动轴(17)底端。5. according to claim 1 or 2 or 4 described a kind of tablet capsule counting device based on machine vision, it is characterized in that: also comprise the vibrating mechanism that vibrates bulk material plate (11), and vibrating mechanism comprises vibrating shaft ( 17), the motor (18) that drives the vibration shaft (17) to generate vibration, the top of the vibration shaft (17) is fixed at the center of the bottom of the bulk material plate (11), and the motor (18) is fixed at the bottom of the vibration shaft (17) end. 6.根据权利要求5所述的一种基于机器视觉的药片胶囊计数装置,其特征在于:CCD相机机构还包括固定设在机箱(15)后侧的支撑杆(3)、可上下调节高度位置或可前后调节水平位置的固定设在支撑杆(3)上的连接块(4)、固定连接在连接块(4)上并向窗口(150)方向伸出的相机夹(7)、通过螺纹孔可旋动的固定设在连接块(4)与支撑杆(3)之间的上下微调旋钮(5)和前后微调旋钮(6),工业CCD相机(9)通过紧固旋钮(8)固定设在相机夹(7)中;通过螺纹孔旋动上下微调旋钮(5),从而连接块(4)沿支撑杆(3)上下移动的同时带动相机夹(7)及工业CCD相机(9)上下移动;通过螺纹孔旋动前后微调旋钮(6),从而连接块(4)沿支撑杆(3)前后移动的同时带动相机夹(7)及工业CCD相机(9)前后移动。6. A kind of tablet capsule counting device based on machine vision according to claim 5, characterized in that: the CCD camera mechanism also includes a support rod (3) fixedly arranged on the rear side of the cabinet (15), the height position of which can be adjusted up and down Or the connection block (4) that can be fixedly arranged on the support rod (3) that can adjust the horizontal position back and forth, the camera clip (7) that is fixedly connected on the connection block (4) and stretches out to the window (150) direction, through the screw thread The hole can be rotated to fix the upper and lower fine-tuning knobs (5) and the front and rear fine-tuning knobs (6) between the connecting block (4) and the support rod (3). The industrial CCD camera (9) is fixed by the fastening knob (8) Set in the camera clip (7); turn the up and down fine-tuning knob (5) through the threaded hole, so that the connecting block (4) moves up and down along the support rod (3) and simultaneously drives the camera clip (7) and the industrial CCD camera (9) Move up and down; turn the front and rear fine-tuning knobs (6) through the threaded holes, so that the connecting block (4) moves back and forth along the support rod (3) and simultaneously drives the camera clip (7) and the industrial CCD camera (9) to move back and forth. 7.根据权利要求1或2或4或6所述的一种基于机器视觉的药片胶囊计数装置,其特征在于:散料板(11)前后两侧固定设有各一个挡板(10)。7. A tablet and capsule counting device based on machine vision according to claim 1 or 2 or 4 or 6, characterized in that: the front and rear sides of the bulk material plate (11) are fixed with a baffle plate (10). 8.根据权利要求7所述的一种基于机器视觉的药片胶囊计数装置,其特征在于:倾斜度调节机构还包括可转动的固定设在丝杠(13)上并带动丝杠(13)转动的手摇手柄(14)或电动手柄。8. A machine vision-based tablet and capsule counting device according to claim 7, characterized in that: the inclination adjustment mechanism also includes a rotatable device fixed on the lead screw (13) and driving the lead screw (13) to rotate Hand handle (14) or electric handle. 9.一种基于机器视觉的药片胶囊计数方法,其特征在于:包括如下步骤:9. A tablet capsule counting method based on machine vision, characterized in that: comprises the steps: 步骤Ⅰ:先通过手摇手柄(14)旋动丝杠(13),丝杠(13)同时带动顶杆(19)向上或向下移动,向上或向下移动的顶杆(19)同时带动散料板(11)后侧上升或下降,从而散料板(11)呈前低后高状态且散料板(11)与水平面之间的倾斜夹角为15-30度;再将待计数的若干个药片胶囊(16)放入散料板(11)中,然后启动电机(18),电机(18)驱动振动轴(17)对散料板(11)产生振动作用,若干个药片胶囊(16)在振动作用下滑入W型沟槽(110)中直至每条W型沟槽(110)的槽底中形成一排排队列状的药片胶囊(16)队列;Step Ⅰ: Rotate the lead screw (13) through the hand handle (14), and the lead screw (13) drives the ejector rod (19) to move up or down at the same time, and the ejector rod (19) moving up or down simultaneously drives The rear side of the bulk material plate (11) rises or falls, so that the bulk material plate (11) is in a state of low front and high rear and the angle of inclination between the bulk material plate (11) and the horizontal plane is 15-30 degrees; Several tablet capsules (16) are put into the bulk material plate (11), then start the motor (18), and the motor (18) drives the vibrating shaft (17) to produce a vibration effect on the bulk material plate (11), and several tablet capsules (16) slide into the W-shaped groove (110) under the action of vibration until forming a row of rows of tablet capsules (16) in the groove bottom of each W-shaped groove (110); 步骤Ⅱ:然后同时打开两个相对设置的条形光源(12),两个相对设置的条形光源(12)同时向散料板(11)发射光并照亮W型沟槽(110)的槽底中形成的一排排队列状的药片胶囊(16)队列;Step II: Then turn on two oppositely arranged bar-shaped light sources (12) at the same time, and the two oppositely arranged bar-shaped light sources (12) simultaneously emit light to the bulk material plate (11) and illuminate the W-shaped groove (110) Tablet capsules (16) queues formed in rows in the groove bottom; 步骤Ⅲ:再启动工业CCD相机(9),通过工业CCD相机(9)对照亮的一排排队列状的药片胶囊(16)队列进行摄像并得到原始的真彩色图像,工业CCD相机(9)再将采集得到的原始的真彩色图像传输给上位机模块(1),上位机模块(1)采用MATLAB工具并通过图像处理方法对原始的真彩色图像进行图像处理,依据图像处理结果对原始的真彩色图像中的若干个药片胶囊(16)进行统计计数得到W型沟槽(110)的槽底中的药片胶囊(16)的个数,药片胶囊(16)的个数显示在显示屏(2)上。Step Ⅲ: Restart the industrial CCD camera (9), take a picture of the tablet capsules (16) queues that are illuminated in rows and rows by the industrial CCD camera (9) and obtain the original true color image, the industrial CCD camera (9) ) and transmit the collected original true-color image to the upper computer module (1), the upper computer module (1) adopts MATLAB tool and carries out image processing to the original true-color image by image processing method, according to the image processing result to the original Several tablet capsules (16) in the true-color image of the statistic count obtain the number of tablet capsules (16) in the groove bottom of W-shaped groove (110), and the number of tablet capsules (16) is shown on the display screen (2) up. 10.根据权利要求9所述的一种基于机器视觉的药片胶囊计数方法,其特征在于:步骤Ⅲ中的图像处理方法包括如下步骤:10. A kind of tablet capsule counting method based on machine vision according to claim 9, is characterized in that: the image processing method in step III comprises the steps: 步骤一:采用MATLAB工具读取原始的真彩色图像;Step 1: Use MATLAB tools to read the original true-color image; 步骤二:图像预处理:包括如下具体步骤:Step 2: Image preprocessing: including the following specific steps: A、图像灰度化处理:依据原始的真彩色图像中每个像素点R、G、B的分量,以R、G、B为权重通过Gray(i,j)函数计算出每个像素点的灰度级,从而将原始的真彩色图像转化为灰度图像,其中,Gray(i,j)=0.299×R(i,j)+0.587×G(i,j)+0.114×B(i,j),Gray(i,j)为灰度图像在(i,j)处的灰度级,R(i,j)为原始的真彩色图像在(i,j)处的红亮度值,G(i,j)为原始的真彩色图像在(i,j)处的绿亮度值,B(i,j)为原始的真彩色图像在(i,j)处的蓝亮度值;A. Image grayscale processing: According to the components of R, G, and B of each pixel in the original true-color image, the weight of each pixel is calculated through the Gray(i,j) function with R, G, and B as weights. Grayscale, so as to convert the original true color image into a grayscale image, where Gray(i,j)=0.299×R(i,j)+0.587×G(i,j)+0.114×B(i, j), Gray(i,j) is the gray level of the grayscale image at (i,j), R(i,j) is the red brightness value of the original true color image at (i,j), G (i, j) is the green brightness value of the original true color image at (i, j), and B(i, j) is the blue brightness value of the original true color image at (i, j); B、图像滤波处理:采用中值滤波算法对经过步骤A处理得到的灰度图像进行中值滤波处理,得到去除噪声信息的灰度图像;B, image filtering processing: adopt median filtering algorithm to carry out median filtering processing to the grayscale image that obtains through step A processing, obtain the grayscale image that removes noise information; C、图像二值化处理:采用二值化阈值分割法并通过f(x)函数对步骤B得到的去除噪声信息的灰度图像进行图像分割处理,将灰度图像中的每个像素点的灰度值逐一与最佳阈值T比较,若像素点的灰度值小于所述的最佳阈值T,则将该像素点的灰度值设置为黑色,并将各个灰度值为黑色的像素点形成的区域标记为背景;若像素点的灰度值不小于所述的最佳阈值T,则将该像素点的灰度值设置为白色,并将各个灰度值为白色的像素点形成的白色联通块标记为药片胶囊(16)的图像;其中,T为最佳阈值;C, image binarization processing: adopt binarization threshold value segmentation method and carry out image segmentation processing to the gray scale image that removes noise information that step B obtains by f(x) function, the each pixel point in the gray scale image The grayscale value is compared with the optimal threshold T one by one, if the grayscale value of the pixel is less than the optimal threshold T, the grayscale value of the pixel is set to black, and the pixel with each grayscale value is black The area formed by the dots is marked as the background; if the gray value of the pixel is not less than the optimal threshold T, the gray value of the pixel is set to white, and the gray value of each pixel is white to form The white connected block mark is the image of the tablet capsule (16); wherein, T is the optimal threshold; 步骤三:图像边缘检测和轮廓特征提取:采用Rober边缘检测算法对步骤C得到的灰度图像中的每个药片胶囊(16)的图像进行图像边缘检测并提取每个药片胶囊(16)的图像的边缘,得到包含每个药片胶囊(16)的图像的轮廓特征的黑白色图像;Step 3: image edge detection and contour feature extraction: use the Rober edge detection algorithm to perform image edge detection on the image of each tablet capsule (16) in the grayscale image obtained in step C and extract the image of each tablet capsule (16) The edge of obtains the black-and-white image that comprises the contour feature of the image of each tablet capsule (16); 步骤四:统计计数:通过MATLAB工具甄别黑色背景下的白色联通块并对输出白色联通块的区域的数量进行计数,从而统计得到白色联通块的个数,从而统计得到药片胶囊(16)的个数。Step 4: Statistical counting: Discriminate the white Unicom blocks under the black background by MATLAB tool and count the area quantity of the output white Unicom blocks, thereby counting the number of white Unicom blocks, thereby obtaining the number of tablets and capsules (16) number.
CN201810636247.0A 2018-06-20 2018-06-20 A kind of tablet capsule counting device and its method based on machine vision Pending CN108545265A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810636247.0A CN108545265A (en) 2018-06-20 2018-06-20 A kind of tablet capsule counting device and its method based on machine vision

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810636247.0A CN108545265A (en) 2018-06-20 2018-06-20 A kind of tablet capsule counting device and its method based on machine vision

Publications (1)

Publication Number Publication Date
CN108545265A true CN108545265A (en) 2018-09-18

Family

ID=63492803

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810636247.0A Pending CN108545265A (en) 2018-06-20 2018-06-20 A kind of tablet capsule counting device and its method based on machine vision

Country Status (1)

Country Link
CN (1) CN108545265A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109712132A (en) * 2018-12-28 2019-05-03 中国科学院长春光学精密机械与物理研究所 A method of it is counted using electronic device counting device automatic screening
CN109720625A (en) * 2019-03-04 2019-05-07 佛山市南海区广工大数控装备协同创新研究院 A kind of roasted eggs number detection device
CN110239797A (en) * 2019-04-22 2019-09-17 达尔嘉(广州)标识设备有限公司 A kind of method of counting of discrete articles
CN110866917A (en) * 2019-12-03 2020-03-06 西安交通大学 A machine vision-based identification method for tablet type and arrangement
CN110927157A (en) * 2018-09-20 2020-03-27 富鼎电子科技(嘉善)有限公司 Detection device and detection method thereof
CN113096095A (en) * 2021-04-12 2021-07-09 江苏理工学院 Machine vision-based adhesive tablet counting method and counting system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0447252A1 (en) * 1990-03-15 1991-09-18 Canon Kabushiki Kaisha Image communication method and apparatus
JPH11279936A (en) * 1998-03-25 1999-10-12 Asahi Chem Ind Co Ltd Creping capability measurement system for creped woven fabric and creping capability measurement
CN104318543A (en) * 2014-01-27 2015-01-28 郑州大学 Board metering method and device based on image processing method
CN104691854A (en) * 2013-12-06 2015-06-10 刘扬 On-line tablet filling detection system
CN206443043U (en) * 2017-02-10 2017-08-29 陈丽红 A kind of fish roe debonding cleaning device
CN107590812A (en) * 2017-09-01 2018-01-16 南京农业大学 Wheat fringe portion small ear identifies method of counting
CN206960278U (en) * 2017-08-04 2018-02-02 中国计量大学 A kind of cereal based on machine vision and beans mass of 1000 kernel and moisture content detection system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0447252A1 (en) * 1990-03-15 1991-09-18 Canon Kabushiki Kaisha Image communication method and apparatus
JPH11279936A (en) * 1998-03-25 1999-10-12 Asahi Chem Ind Co Ltd Creping capability measurement system for creped woven fabric and creping capability measurement
CN104691854A (en) * 2013-12-06 2015-06-10 刘扬 On-line tablet filling detection system
CN104318543A (en) * 2014-01-27 2015-01-28 郑州大学 Board metering method and device based on image processing method
CN206443043U (en) * 2017-02-10 2017-08-29 陈丽红 A kind of fish roe debonding cleaning device
CN206960278U (en) * 2017-08-04 2018-02-02 中国计量大学 A kind of cereal based on machine vision and beans mass of 1000 kernel and moisture content detection system
CN107590812A (en) * 2017-09-01 2018-01-16 南京农业大学 Wheat fringe portion small ear identifies method of counting

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110927157A (en) * 2018-09-20 2020-03-27 富鼎电子科技(嘉善)有限公司 Detection device and detection method thereof
CN109712132A (en) * 2018-12-28 2019-05-03 中国科学院长春光学精密机械与物理研究所 A method of it is counted using electronic device counting device automatic screening
CN109712132B (en) * 2018-12-28 2021-03-19 中国科学院长春光学精密机械与物理研究所 Method for automatically screening and counting by using electronic device counting device
CN109720625A (en) * 2019-03-04 2019-05-07 佛山市南海区广工大数控装备协同创新研究院 A kind of roasted eggs number detection device
CN110239797A (en) * 2019-04-22 2019-09-17 达尔嘉(广州)标识设备有限公司 A kind of method of counting of discrete articles
CN110239797B (en) * 2019-04-22 2021-11-16 达尔嘉(广州)标识设备有限公司 Counting method of discrete articles
CN110866917A (en) * 2019-12-03 2020-03-06 西安交通大学 A machine vision-based identification method for tablet type and arrangement
CN113096095A (en) * 2021-04-12 2021-07-09 江苏理工学院 Machine vision-based adhesive tablet counting method and counting system

Similar Documents

Publication Publication Date Title
CN108545265A (en) A kind of tablet capsule counting device and its method based on machine vision
CN213456719U (en) Detection apparatus for curved surface screen defect
CN110068518A (en) Machine-made Sand quality detection apparatus and its detection method
JP6406590B2 (en) Droplet measuring system, droplet measuring method and program
CN203233507U (en) Video signal processing equipment
CN106770365B (en) Powder sample impurity analyzer
CN210136151U (en) A kind of machine-made sand quality testing equipment
US20220053170A1 (en) Goods information collection device
CN108124142A (en) Images steganalysis system and method based on RGB depth of field camera and EO-1 hyperion camera
CN206505030U (en) A kind of automatic line detector of automobile stamping
CN206488848U (en) A kind of big visual field multiple spot three-dimensional vibrating measurement apparatus
JP4155942B2 (en) Angle measurement device for powder accumulation layer
CN103454283A (en) Line detection system and method
JP7324485B2 (en) Droplet measurement system, droplet measurement method, and program
CN1710606A (en) Non-contact vision paper-counting method and machine thereof
CN113245222B (en) Visual real-time detection and sorting system and sorting method for foreign matters in panax notoginseng
CN210222058U (en) Wind direction detection device for air outlet of cleaning fan
CN210831116U (en) Dripping form image acquisition device in dripping process of dripping pills
CN113409297A (en) Aggregate volume calculation method, particle form grading data generation method, system and equipment
CN101480308A (en) Method for automatically displaying image in positive direction after rotation of digital photo frame and device thereof
JP7155375B1 (en) Measurement system, information processing device, information processing method and program
CN106413280A (en) Automatic surface mounting machine feeder element position correction device and automatic correction method based on image processing
CN110686144A (en) Dripping form image acquisition device in dripping process of dripping pills
CN114926409A (en) Intelligent industrial component data acquisition method
CN110133000A (en) A fully automatic microscope visual imaging surface inspection machine

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20180918

RJ01 Rejection of invention patent application after publication