TWI731484B - Method and system for building medication library and managing medication via the image of its blister package - Google Patents

Method and system for building medication library and managing medication via the image of its blister package Download PDF

Info

Publication number
TWI731484B
TWI731484B TW108143018A TW108143018A TWI731484B TW I731484 B TWI731484 B TW I731484B TW 108143018 A TW108143018 A TW 108143018A TW 108143018 A TW108143018 A TW 108143018A TW I731484 B TWI731484 B TW I731484B
Authority
TW
Taiwan
Prior art keywords
image
drug
corrected
blister package
contour
Prior art date
Application number
TW108143018A
Other languages
Chinese (zh)
Other versions
TW202121283A (en
Inventor
鍾聖倫
伍森德
陳智芳
Original Assignee
台灣基督長老教會馬偕醫療財團法人馬偕紀念醫院
國立臺灣科技大學
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 台灣基督長老教會馬偕醫療財團法人馬偕紀念醫院, 國立臺灣科技大學 filed Critical 台灣基督長老教會馬偕醫療財團法人馬偕紀念醫院
Priority to TW108143018A priority Critical patent/TWI731484B/en
Publication of TW202121283A publication Critical patent/TW202121283A/en
Application granted granted Critical
Publication of TWI731484B publication Critical patent/TWI731484B/en

Links

Images

Abstract

Disclosed herein is an improved system for managing a medication and a method of building a medication library via images of a blister package of the medication. The method comprises steps of: (a) respectively obtaining a first image and a second image of a blister package of the medication, in which the first image and the second image include a first side and a second side of the blister package of the medication, respectively; (b) subjecting the first image and the second image to an image rectification treatment to respectively produce a first rectified image and a second rectified image; (c) juxtaposing the first rectified image and the second rectified image to produce a combined image; (d) processing the combined image to produce a reference image; and (e) building the medication library with the aid of the reference image. The system comprises an image processor, which is programmed with instructions to execute the present method.

Description

經由藥物泡型包裝影像建立藥物資料庫及管理藥物之方法及系統Method and system for establishing drug database and managing drugs through drug blister packaging images

本揭示內容是關於藥物管理系統的領域,特別是有關於一種可經由藥物泡型包裝影像來分類及識別該藥物的方法及系統。The present disclosure relates to the field of drug management systems, in particular to a method and system that can classify and identify drugs through drug blister packaging images.

對於醫院系統的順利運作以及提供優質病患照護來說,藥品核實確實與否是,是保證病患用藥安全的基本先決條件。雖然全自動配藥櫃(automated dispensing cabinets,ADCs)被引入醫療院所已有20年的歷史,但仍存在藥事上的疏失。由於全自動配藥櫃的給藥在很大程度上仍仰賴臨床人員對於標準流程的精確遵守,特別是依賴人眼經由藥物外觀來識別該藥物,這樣一來將不可避免地產生外觀辨識錯誤的狀況。為了降低人為疏失,例如誤將相似的藥品存放在錯誤的藥櫃、或是臨床人員可能從鄰近的藥櫃上拿到外觀上看起來相似的藥品,有必要對藥物管理系統做進一步的改良。For the smooth operation of the hospital system and the provision of high-quality patient care, drug verification is a basic prerequisite for ensuring the safety of patients' medication. Although automated dispensing cabinets (ADCs) have been introduced into medical institutions for 20 years, there are still lapses in pharmaceutical matters. Since the administration of the fully automatic dispensing cabinet still relies to a large extent on the clinical staff’s precise compliance with the standard procedures, in particular, it relies on the human eye to identify the drug through the appearance of the drug, which will inevitably lead to the appearance of identification errors. . In order to reduce human error, such as storing similar medicines in the wrong medicine cabinet by mistake, or clinical staff may get medicines that look similar in appearance from a neighboring medicine cabinet, it is necessary to make further improvements to the medicine management system.

深度學習(deep learning)是機器學習系列中,基於多級別學習數據表示(representation)的一種方法。這些方法是透過組合簡單但非線性的模塊(module)所獲得,每個模塊將一個級別的表示轉換為更高、更抽象一點的級別來表示。通過這些轉換足夠的組合,可以學習較為複雜的功能(例如分類任務),例如將深度學習應用於臨床的藥事管理。在深度學習可識別物體外觀的基礎功能上,輔以系統性地對藥物外觀進行影像處理之後,深度學習有望為目前藥物分配技術的缺點帶來解決之道。Deep learning is a method based on multi-level learning data representation in the machine learning series. These methods are obtained by combining simple but non-linear modules, each of which transforms a level of representation into a higher and more abstract level. Through a sufficient combination of these transformations, more complex functions (such as classification tasks) can be learned, such as the application of deep learning to clinical pharmaceutical management. Based on the basic function of deep learning to recognize the appearance of objects, supplemented by the systematic image processing of the appearance of drugs, deep learning is expected to bring solutions to the shortcomings of current drug dispensing technology.

然而,考慮到涉及某些外觀相似之藥物包裝的種類繁多,且一般藥物包裝係由正面與反面構成。為了增加短時間內的辨識效率,有必要提供一種可精準地取得藥物包裝外觀的影像處理方法,以利應用至深度學習系統中,提升深度學習成效及辨識精準度。However, considering that there are many types of drug packages that are similar in appearance, and general drug packages are composed of front and back sides. In order to increase the identification efficiency in a short time, it is necessary to provide an image processing method that can accurately obtain the appearance of the drug packaging, so that it can be applied to a deep learning system to improve the effectiveness of deep learning and the accuracy of identification.

鑑於上述,現有技術有必要提供一種用於藥物管理(例如,經由藥物泡型包裝來分類和識別該藥物)的改善方法及系統。In view of the above, it is necessary in the prior art to provide an improved method and system for drug management (for example, to classify and identify the drug via a drug blister package).

為了給讀者提供基本的理解,以下提供本揭示內容的簡要發明內容。此發明內容不是本揭示內容的廣泛概述,同時非用來識別本發明的關鍵/必需元件或勾勒本發明的範圍。其唯一目的是以簡化的概念形式呈現本揭示內容的一些概念,以作為呈現於後文中更詳細描述的序言。In order to provide readers with a basic understanding, the following provides a brief summary of the present disclosure. This summary of the invention is not an extensive overview of the disclosure, and is not used to identify the key/essential elements of the invention or outline the scope of the invention. Its sole purpose is to present some concepts of this disclosure in a simplified conceptual form as a prelude to the more detailed description presented later.

如本文所體現和廣泛描述的,本揭示內容的目的是提供一種改善的藥品管理系統以及透過該系統識別臨床藥物的實施方法,藉此可大幅改善配藥的效率及精確性。As embodied and broadly described herein, the purpose of the present disclosure is to provide an improved drug management system and an implementation method for identifying clinical drugs through the system, thereby greatly improving the efficiency and accuracy of dispensing drugs.

本揭示內容的一態樣是關於一種用以建立一藥物泡型包裝影像之藥物資料庫的電腦實施方法。在某些實施方式中,該方法包含:(a) 分別取得該藥物泡型包裝之一第一影像及一第二影像,其中該第一影像及該第二影像分別包含該藥物泡型包裝之一第一面及一第二面;(b) 分別對該第一影像及該第二影像進行影像糾正(image rectification),以產生一糾正後第一影像及一糾正後第二影像;(c) 規整(juxtapose)該糾正後第一影像及該糾正後第二影像,以產生一合併影像;(d) 處理該合併影像以產生一參考影像;以及(e)借助於該參考影像以建立該藥物資料庫。One aspect of the present disclosure relates to a computer-implemented method for building a drug database of drug blister packaging images. In some embodiments, the method includes: (a) obtaining a first image and a second image of the drug blister package, respectively, wherein the first image and the second image respectively include the drug blister package A first side and a second side; (b) performing image rectification on the first image and the second image respectively to generate a corrected first image and a corrected second image; (c) ) Juxtapose the corrected first image and the corrected second image to generate a merged image; (d) process the merged image to generate a reference image; and (e) use the reference image to create the Drug database.

根據本揭示內容的某些實施方式,在步驟(b)中,可以下述步驟來對該第一影像進行影像糾正:(b-1) 提供一參考矩形;(b-2) 選定該第一影像中四個角點,其中該四個角點構成一四邊形;(b-3) 基於步驟(b-1)提供之該參考矩形與步驟(b-2)選定之該四邊形的對應關係,計算該參考矩形與該四邊形之對應關係的一第一單應性矩陣(homography matrix);以及(b-4) 根據該第一單應性矩陣對該第一影像進行透視校正(perspective correction),以獲得該糾正後第一影像。According to some embodiments of the present disclosure, in step (b), the first image can be corrected by the following steps: (b-1) provide a reference rectangle; (b-2) select the first image Four corner points in the image, among which the four corner points constitute a quadrilateral; (b-3) Based on the correspondence between the reference rectangle provided in step (b-1) and the quadrilateral selected in step (b-2), calculate A first homography matrix of the correspondence between the reference rectangle and the quadrilateral; and (b-4) perform perspective correction on the first image according to the first homography matrix to Obtain the corrected first image.

根據本揭示內容的某些實施方式,前述步驟(b-2)之該四邊形可對應該藥物泡型包裝第一面之一輪廓。According to some embodiments of the present disclosure, the quadrilateral in the aforementioned step (b-2) can correspond to an outline of the first side of the drug blister package.

較佳地,前述步驟(b)中,以下述步驟來對該第二影像進行影像糾正:(b-i) 基於該糾正後第一影像與該第二影像之間的對應關係,計算兩者間的一第二單應性矩陣;以及(b-ii) 根據該第二單應性矩陣對該第二影像進行透視校正,以獲得該糾正後第二影像。Preferably, in the aforementioned step (b), the following steps are used to perform image correction on the second image: (bi) Based on the corresponding relationship between the corrected first image and the second image, calculate the A second homography matrix; and (b-ii) performing perspective correction on the second image according to the second homography matrix to obtain the corrected second image.

根據本揭示內容的某些實施方式,步驟(c)包含:(c-1)   提取該糾正後第一影像及該糾正後第二影像中,該藥物泡型包裝第一面及第二面之輪廓,以分別產生一第一輪廓影像及一第二輪廓影像;(c-2) 識別該第一輪廓影像及該第二輪廓影像中各輪廓的角點,以確定該角點之座標;(c-3) 根據步驟(c-2)之該座標,旋轉步驟(c-1)之該第一輪廓影像及該第二輪廓影像,以分別形成一第一處理影像及一第二處理影像;以及(c-4) 規整步驟(c-3)之該第一處理影像及第二處理影像,以產生該合併影像。According to some embodiments of the present disclosure, step (c) includes: (c-1) extracting the first and second sides of the drug blister package from the corrected first image and the corrected second image Contours to generate a first contour image and a second contour image respectively; (c-2) identifying the corner points of each contour in the first contour image and the second contour image to determine the coordinates of the corner points; c-3) According to the coordinates of step (c-2), rotate the first contour image and the second contour image of step (c-1) to form a first processed image and a second processed image, respectively; And (c-4) the first processed image and the second processed image of the regularization step (c-3) to generate the combined image.

較佳地,是以一直線轉換演算法或一質心演算法來執行步驟(c-2)。Preferably, step (c-2) is performed by a linear conversion algorithm or a centroid algorithm.

較佳地,是以一機器學習演算法來執行步驟(d)。Preferably, step (d) is performed by a machine learning algorithm.

根據本揭示內容的某些實施方式,所述第一面與第二面分別是該藥物泡型包裝的正面及反面。According to some embodiments of the present disclosure, the first side and the second side are the front side and the back side of the drug blister package, respectively.

本揭示內容的另一態樣是關於一種藥物管理系統,其包含一以前述電腦實施方法建立的藥物資料庫、一影像擷取裝置、一影像處理器以及一機器學習處理器,設以實現藥物管理。Another aspect of the present disclosure relates to a medication management system, which includes a medication database established by the aforementioned computer-implemented method, an image capture device, an image processor, and a machine learning processor, designed to implement medication management.

具體而言,所述藥物資料庫係用以提供一參考影像;該影像擷取裝置用以擷取一藥物的一泡型包裝之影像,其中該影像擷取裝置包含一透明板體,用以使該藥物放置其上;一第一影像擷取單元,設置於該透明板體之一側,用以以一第一角度擷取該藥物的一第一影像,其中該第一影像包含該藥物泡型包裝之一第一面;以及一第二影像擷取單元,設置於該透明板體之另一側,用以以一第二角度擷取該藥物的一第二影像,其中該第二影像包含該藥物泡型包裝之一第二面。該影像處理器則經指令編程執行一第一電腦實施方法,係用於產生一候選影像,其中該第一電腦實施方法包含:(a) 分別對該第一影像及該第二影像進行影像糾正,以分別產生一糾正後第一影像及一糾正後第二影像;以及(b)  規整該糾正後第一影像及該糾正後第二影像,以產生該候選影像。機器學習處理器係經指令編程執行一第二電腦實施方法,用於比對該候選影像與如請求項1所述之電腦實施方法建立的該藥物資料庫之參考影像。Specifically, the drug database is used to provide a reference image; the image capture device is used to capture an image of a blister pack of a drug, and the image capture device includes a transparent plate for Place the medicine on it; a first image capturing unit is arranged on one side of the transparent plate for capturing a first image of the medicine at a first angle, wherein the first image contains the medicine A first side of the blister package; and a second image capturing unit, arranged on the other side of the transparent plate, for capturing a second image of the medicine at a second angle, wherein the second The image contains a second side of the drug blister package. The image processor is programmed to execute a first computer-implemented method for generating a candidate image through instruction programming, wherein the first computer-implemented method includes: (a) performing image correction on the first image and the second image respectively , To respectively generate a corrected first image and a corrected second image; and (b) regularizing the corrected first image and the corrected second image to generate the candidate image. The machine learning processor is programmed with instructions to execute a second computer-implemented method for comparing the candidate image with the reference image of the drug database established by the computer-implemented method described in claim 1.

根據本揭示內容的某些實施方式,前述步驟(b)包含:(b-1)  提取該糾正後第一影像及該糾正後第二影像中,該藥物泡型包裝之該第一面及該第二面之輪廓,以分別產生一第一輪廓影像及一第二輪廓影像;(b-2) 識別該第一輪廓影像及該第二輪廓影像中各輪廓的角點,以確定該角點之座標;(b-3) 根據步驟(b-2)的該座標,旋轉步驟(b-1)之該第一輪廓影像及該第二輪廓影像,以分別形成一第一處理影像及一第二處理影像;以及(b-4)   規整步驟(b-3)之該第一處理影像及第二處理影像,以產生該候選影像。According to some embodiments of the present disclosure, the aforementioned step (b) includes: (b-1) extracting the first side and the first side of the drug blister package from the corrected first image and the corrected second image The contour of the second surface to generate a first contour image and a second contour image respectively; (b-2) Identify the corner points of each contour in the first contour image and the second contour image to determine the corner point (B-3) According to the coordinates of step (b-2), rotate the first contour image and the second contour image of step (b-1) to form a first processed image and a second Two processing images; and (b-4) the first processing image and the second processing image of the regularization step (b-3) to generate the candidate image.

根據本揭示內容的較佳實施方式,該第一面與該第二面分別是該藥物泡型包裝的正面及反面。According to a preferred embodiment of the present disclosure, the first side and the second side are the front and back sides of the drug blister package, respectively.

根據本揭示內容某些實施方式,該第一角度以及該第二角度分別相對於該透明板體之水平面為40至90度。According to some embodiments of the present disclosure, the first angle and the second angle are respectively 40 to 90 degrees with respect to the horizontal plane of the transparent plate.

為了使本揭示內容的敘述更加詳盡與完備,下文針對了本發明的實施態樣與具體實施例提出了說明性的描述;但這並非實施或運用本發明具體實施例的唯一形式。實施方式中涵蓋了多個具體實施例的特徵以及用以建構與操作這些具體實施例的方法步驟與其順序。然而,亦可利用其他具體實施例來達成相同或均等的功能與步驟順序。In order to make the description of the present disclosure more detailed and complete, the following provides an illustrative description for the implementation aspects and specific embodiments of the present invention; this is not the only way to implement or use the specific embodiments of the present invention. The implementation manners cover the characteristics of a number of specific embodiments and the method steps and sequences used to construct and operate these specific embodiments. However, other specific embodiments can also be used to achieve the same or equal functions and sequence of steps.

I.  定義I. Definition

為了便於說明,此處統整性地說明本說明書、實施例以及後附的申請專利範圍中所記載的特定術語。除非本說明書另有定義,此處所用的科學與技術詞彙之含義與本發明所屬技術領域中具有通常知識者所理解與慣用的意義相同。此外,在不和上下文衝突的情形下,本說明書所用的單數名詞涵蓋該名詞的複數型;而所用的複數名詞時亦涵蓋該名詞的單數型。具體而言,除非上下文另有明確說明,本文和後附的申請專利範圍所使用的單數形式「一」(a及an)包含複數形式。此外,在本說明書與申請專利範圍中,「至少一」(at least one)與「一或更多」(one or more)等表述方式的意義相同,兩者都代表包含了一、二、三或更多。For ease of description, the specific terms described in the specification, the embodiments and the appended patent scope are collectively described here. Unless otherwise defined in this specification, the scientific and technical terms used herein have the same meaning as understood and used by those with ordinary knowledge in the technical field of the present invention. In addition, without conflict with the context, the singular nouns used in this specification cover the plural nouns; and the plural nouns used also cover the singular nouns. Specifically, unless the context clearly indicates otherwise, the singular form "one" (a and an) used in the scope of the patent application herein and appended includes plural forms. In addition, in this specification and the scope of the patent application, expressions such as "at least one" and "one or more" have the same meaning, and both of them mean that they include one, two, and three. Or more.

雖然用以界定本發明較廣範圍的數值範圍與參數皆是約略的數值,此處已盡可能精確地呈現具體實施例中的相關數值。然而,任何數值本質上不可避免地含有因個別測試方法所致的標準偏差。在此處,「約」(about)通常係指實際數值在一特定數值或範圍的正負10%、5%、1%或0.5%之內。或者是,「約」一詞代表實際數值落在平均值的可接受標準誤差之內,視本發明所屬技術領域中具有通常知識者的考量而定。除了實驗例之外,或除非另有明確的說明,當可理解此處所用的所有範圍、數量、數值與百分比(例如用以描述材料用量、時間長短、溫度、操作條件、數量比例及其他相似者)均經過「約」的修飾。因此,除非有相反的說明,本說明書與附隨申請專利範圍所揭示的數值參數皆為約略的數值,且可視需求而更動。至少應將這些數值參數理解為所指出的有效位數與套用一般進位法所得到的數值。在此處,將數值範圍表示成由一端點至另一段點或介於二端點之間;除非另有說明,此處所述的數值範圍皆包含端點。Although the numerical ranges and parameters used to define the broader scope of the present invention are approximate numerical values, the relevant numerical values in the specific embodiments are presented here as accurately as possible. However, any value inevitably contains standard deviations due to individual test methods. Here, "about" usually means that the actual value is within plus or minus 10%, 5%, 1%, or 0.5% of a specific value or range. Or, the word "about" means that the actual value falls within the acceptable standard error of the average value, depending on the consideration of a person with ordinary knowledge in the technical field of the present invention. In addition to the experimental examples, or unless otherwise clearly stated, all ranges, quantities, values and percentages used herein (for example, used to describe the amount of material, length of time, temperature, operating conditions, quantity ratios and other similar Those) have been modified by "about". Therefore, unless otherwise stated, the numerical parameters disclosed in this specification and the accompanying patent scope are approximate values and can be changed according to requirements. At least these numerical parameters should be understood as the indicated effective number of digits and the value obtained by applying the general carry method. Here, the numerical range is expressed from one end point to another point or between two end points; unless otherwise specified, the numerical range described here includes the end points.

本文使用的「泡型包裝」(blister pack或blister package)一詞涵蓋產品被包含在片體材料之間的任何類型的分層包裝;其中該些片體材料可藉由所屬技術領域中具有通常知識者熟知的方法黏合或封裝,舉例來說,這些片體可藉由熱及/或壓力活化膠加以黏合。可從市售獲得這些可做為單獨片體(用於手工包裝)或作為捲料上連續卷片(用於機器包裝)的片體材料。泡型包裝的主要結構是由可成形網(通常是熱塑性塑膠)製成的空腔或袋體。空腔或袋體足夠大以容納在在泡型包裝中的物品。根據應用,泡型包裝可具有熱塑性材料的背襯。對於製藥領域,泡型包裝常用作藥片的單劑量包裝,且包含印刷在該泡型包裝反面的藥物資訊。此外,這些片體有各種厚度可以選擇。一般而言,將空腔或袋體裝有單劑量藥丸的那面視為正面,將另一印刷藥物資訊的面視為反面。As used herein, the term "blister pack" (blister pack or blister package) covers any type of layered packaging in which the product is contained between sheet materials; wherein these sheet materials can be used in the technical field. It is bonded or encapsulated by methods well known to those skilled in the art. For example, these sheets can be bonded by heat and/or pressure activated glue. These are commercially available as individual sheets (for manual packaging) or as continuous rolls on rolls (for machine packaging). The main structure of blister packaging is a cavity or bag made of a formable mesh (usually thermoplastic). The cavity or bag is large enough to contain the items in the blister pack. Depending on the application, the blister pack may have a backing of thermoplastic material. For the pharmaceutical field, blister packaging is often used as a single-dose packaging for tablets, and contains drug information printed on the reverse side of the blister packaging. In addition, these sheets are available in various thicknesses. Generally speaking, the side of the cavity or bag containing the single-dose pill is regarded as the front side, and the side with the drug information printed on the other side is regarded as the back side.

本文使用的影像「糾正」(rectification)或「校正」(correction),係指經特定手段,將一非正視角度拍攝、因而導致影像內容目標物變形的失真原始影像,改正回具有正視角度及具有統一比例尺及統一座標方位的正射影像(orthophoto)的一種過程。具體的手段則可透過數學原理,例如矩陣或多元一次方程組來求得正視影像。The “rectification” or “correction” of the image used in this article refers to the use of specific methods to correct a distorted original image that has been shot at a non-frontal angle and thus deforms the target object in the image content to have a frontal angle and A process of orthophoto that unifies the scale and coordinates. Specific methods can be obtained through mathematical principles, such as matrices or multivariate linear equations.

本文使用的「規整」(juxtapose)一詞是指將兩個物件並排對齊放置。在本揭示內容中,具體是指將兩張影像,特別是經影像處理後、規格尺寸相同的兩張影像並排放置的步驟。在文中,為了明確地說明相關內容,可以相似的「對齊放置」、「並排」、「合併」等詞來替換說明。The term "juxtapose" used in this article refers to placing two objects side by side. In the present disclosure, it specifically refers to the step of placing two images, especially two images with the same size after image processing, side by side. In the text, in order to clearly explain the relevant content, similar words such as "alignment", "side by side", and "merge" can be used to replace the description.

II. 本發明實施方式II. Implementation of the present invention

本發明旨在提供一種改良的影像處理,並配合誘導式深度學習方法,藉以解決習知臨床配藥所面臨的辨識失誤問題。此外,本發明亦旨在發展一種自動藥物驗證(automatic medication verification,AMV)設備,採用實時操作系統,藉以減低臨床人員的工作負荷。The present invention aims to provide an improved image processing, combined with an inductive deep learning method, so as to solve the problem of identification errors faced by conventional clinical dispensing. In addition, the present invention also aims to develop an automatic medication verification (AMV) device that uses a real-time operating system to reduce the workload of clinical staff.

具體來說,所謂誘導式的深度學習是指將特徵或影像輸入演算法之前,處理或醒目化該些特徵或影像的方法,藉此以更強調的方式學習該些特徵資訊。為了更好地劃分所識別的目標並曝光固有的描述性特徵,一般是藉由各種影像處理步驟以達成特徵處理,該些步驟是將藥物的泡型包裝外觀的正反兩面剪裁影像整合至一固定尺寸的模板中,從而利於後續學習網路的分類過程。Specifically, the so-called inductive deep learning refers to a method of processing or highlighting the features or images before inputting the features or images into the algorithm, so as to learn the feature information in a more emphasized manner. In order to better divide the identified target and expose the inherent descriptive features, various image processing steps are generally used to achieve feature processing. These steps are to integrate the front and back cut images of the appearance of the drug blister package into one. In a fixed-size template, it facilitates the subsequent classification process of the learning network.

1.1. 建立藥物資料庫的方法Method of establishing drug database

本揭示內容的第一態樣是關於一種用於在電腦可讀取儲存媒體中建立藥物資料庫的方法100,並配合第1圖(根據本揭示內容一實施方式所繪示的流程圖)來說明之。The first aspect of the present disclosure relates to a method 100 for establishing a drug database in a computer-readable storage medium, and is used in conjunction with Figure 1 (a flowchart according to an embodiment of the present disclosure). Explain it.

須說明的是,在實施方法100之前,可藉由任何已知的方式,例如一影像擷取裝置(例如,攝像機)來擷取一藥物泡型包裝的一或多個原始影像。接著,在本揭示內容方法100的步驟102中,經擷取的影像被自動地轉發到其嵌有用於執行本發明方法100之指令的裝置及/或系統,用以後續建立藥物資料庫之步驟。It should be noted that before the method 100 is implemented, one or more original images of a drug blister package can be captured by any known method, such as an image capturing device (for example, a camera). Then, in step 102 of the method 100 of the present disclosure, the captured image is automatically forwarded to the device and/or system embedded with instructions for executing the method 100 of the present invention for the subsequent step of establishing a drug database .

在方法100中,首先分別取得一藥物在泡型包裝的整體外觀的第一影像及第二影像(步驟102)。第一影像包含藥物泡型包裝的第一面,而第二影像則包含藥物泡型包裝的第二面。具體來說,泡型包裝是一種藥片的單劑量包裝,且包含印刷在該泡型包裝反面的藥物資訊。在特定實施方式中,由於泡型包裝係由上下兩片體材料壓合而成,故具有兩面。一般而言,將空腔或袋體裝有單劑量藥丸的一面視為正面,且將印有印刷藥物資訊的一面視為反面。換句話說,在本揭示內容中,所述該藥物泡型包裝之第一面或第二面,即分別指藥物泡型包裝的正面或反面。In the method 100, the first image and the second image of the overall appearance of a drug in the blister package are first obtained respectively (step 102). The first image includes the first side of the drug blister package, and the second image includes the second side of the drug blister package. Specifically, a blister package is a single-dose package of tablets and contains drug information printed on the reverse side of the blister package. In a specific embodiment, since the blister package is formed by pressing two upper and lower sheets of material, it has two sides. Generally speaking, the side of the cavity or bag containing the single-dose pill is regarded as the front side, and the side with printed drug information is regarded as the back side. In other words, in the present disclosure, the first side or the second side of the drug blister package refers to the front side or the back side of the drug blister package, respectively.

取得包含藥物泡型包裝之完整面的第一影像及第二影像後,分別對第一影像及第二影像進行影像糾正(image rectification),以產生糾正後第一影像及糾正後第二影像(步驟104)。After obtaining the first image and the second image including the complete surface of the drug blister package, image rectification is performed on the first image and the second image respectively to generate the corrected first image and the corrected second image ( Step 104).

具體而言,在步驟104中,可以分別對第一影像及第二影像進行影像糾正。配合第1圖,在步驟104中,係以步驟1041、1043、1045及1047來對第一影像進行影像糾正;而步驟1042及1044則用以對第二影像進行影像糾正。首先,步驟1041為提供一參考矩形。在本揭示內容中,參考矩形具體是一虛擬正視影像,且對齊笛卡兒平面座標系之X軸與Y軸的正四邊形;較佳是根據一同為矩形的參考背景物,選定在特定照相視野內具有特定長寬比的一虛擬矩形。在本案較佳實施例中,可將用以放置承載欲拍攝藥物之透明板體的固定尺寸作為背景參考物,選定正視拍攝視野內具有相同長寬比之透明板體的四個角點所構成正四邊形,以作為參考矩形。在本案之另一實施例中,亦可將特定正視視野內呈現的藥物泡型包裝的輪廓(所對應的固定尺寸與長寬比的四邊形)來作為參考矩形。Specifically, in step 104, image correction may be performed on the first image and the second image respectively. In accordance with Figure 1, in step 104, steps 1041, 1043, 1045, and 1047 are used to perform image correction on the first image; and steps 1042 and 1044 are used to perform image correction on the second image. First, step 1041 is to provide a reference rectangle. In the present disclosure, the reference rectangle is specifically a virtual front view image, and is aligned with the X-axis and Y-axis of the Cartesian plane coordinate system. It is preferably based on the reference background object that is also a rectangle, and is selected in the specific photographic field of view. A virtual rectangle with a specific aspect ratio inside. In the preferred embodiment of the present case, the fixed size for placing the transparent plate carrying the drug to be photographed can be used as the background reference object, and the four corner points of the transparent plate with the same aspect ratio in the front view shooting field can be selected to form A regular quadrilateral, as a reference rectangle. In another embodiment of this case, the outline of the drug blister package (corresponding to a quadrilateral with a fixed size and an aspect ratio) presented in a specific frontal field of view can also be used as the reference rectangle.

接著,在第一影像中,選定可構成一個四邊形的任意四個角點(步驟1043)。具體而言,任意選擇可構成一四邊形的四個角點,該四邊形可以不限任意形狀,例如:梯形、菱形、平行四邊形、任意四邊形或正四邊形。在本揭示內容的較佳實施方式中,所述四邊形是對應前述透明板體的四個角點所形成的四邊形;在另一較佳實施方式中,所述四邊形係對應該藥物泡型包裝第一面的輪廓。具體來說,可視情況而定,使所述四邊形對應於藥物泡型包裝的正面或反面輪廓。Then, in the first image, any four corner points that can form a quadrilateral are selected (step 1043). Specifically, the four corner points of a quadrilateral can be formed by arbitrary selection, and the quadrilateral can have any shape, such as a trapezoid, a rhombus, a parallelogram, an arbitrary quadrilateral, or a regular quadrilateral. In a preferred embodiment of the present disclosure, the quadrilateral is a quadrilateral formed corresponding to the four corners of the aforementioned transparent plate; in another preferred embodiment, the quadrilateral corresponds to the first drug blister package. Silhouette of one side. Specifically, depending on the situation, the quadrilateral is made to correspond to the front or back contour of the drug blister package.

對第一影像定義出一四邊形之後,可接續進行求找第一單應性矩陣(homography matrix)的步驟,如第1圖步驟1045。具體作法是根據步驟1041的參考矩形與步驟1043之選定四邊形兩者之間的對應關係,來計算該參考矩形與該四邊形之對應關係的第一單應性矩陣。本揭示內容的具體實施方式中,可依照特定正視視野內呈現的藥物泡型包裝的輪廓與第一影像中選定的藥物泡型包裝之輪廓,兩者之間於座標系上的座標對應關係,求得第一單應性矩陣。在另一具體實施方式中,是依照正視拍攝視野內透明板體的四個角點所構成的參考矩形,以及第一影像中前述相同角點所形成之四邊形的對應關係,以求得第一單應性矩陣。單應性矩陣的求解方式為本領域之通常知識,在此不予以贅述。After defining a quadrilateral for the first image, the step of finding the first homography matrix can be continued, as shown in step 1045 in Figure 1. The specific method is to calculate the first homography matrix of the correspondence between the reference rectangle and the quadrilateral according to the correspondence between the reference rectangle in step 1041 and the selected quadrilateral in step 1043. In the specific embodiments of the present disclosure, the outline of the drug blister package presented in a specific frontal field of view and the outline of the drug blister package selected in the first image can be based on the coordinate correspondence between the two in the coordinate system, Find the first homography matrix. In another specific embodiment, the corresponding relationship between the reference rectangle formed by the four corner points of the transparent plate in the field of view of the front view and the quadrilateral formed by the same corner points in the first image is used to obtain the first The homography matrix. The solution method of the homography matrix is common knowledge in the field, so I won't repeat it here.

求得第一單應性矩陣之後,則可對前述步驟102取得之第一影像進行透視校正(perspective correction),以獲得糾正後第一影像。經由前述步驟1041–1047獲得的糾正後第一影像是呈現藥物泡型包裝之第一面的正視影像,以利後續提取輪廓及規整步驟的進行。After the first homography matrix is obtained, perspective correction can be performed on the first image obtained in step 102 to obtain the corrected first image. The corrected first image obtained through the aforementioned steps 1041-1047 is a front-view image showing the first side of the drug blister package, so as to facilitate the subsequent steps of contour extraction and regularization.

繼續配合第1圖,方法100之步驟104中,還可以以下步驟對第二影像進行糾正。步驟包含:基於糾正後第一影像與第二影像之間的對應關係,計算兩者之間的第二單應性矩陣(步驟1042);以及根據所述第二單應性矩陣對第二影像進行透視校正,以獲得糾正後第二影像(步驟1044)。具體來說,糾正後第一影像與第二影像均包含相同的參考背景物(例如,前述之透明板體),且糾正後第一影像應為一正視影像,故而可根據糾正後第一影像與第二影像之間的關係,求得兩者之間的第二單應性矩陣。接著根據第二單應性矩陣,對第二影像進行透視校正,以獲得糾正後第二影像。如同前述,糾正後第二影像是呈現藥物泡型包裝之第二面的正視影像。根據本揭示內容的一特定實施方式,經糾正後,藥物泡型包裝的第二面在糾正後第二影像內的相對位置與第一面在糾正後第一影像內的相對位置相同。Continuing to cooperate with Figure 1, in step 104 of the method 100, the second image can also be corrected in the following steps. The steps include: calculating a second homography matrix between the first image and the second image based on the corresponding relationship between the corrected first image and the second image (step 1042); and comparing the second image according to the second homography matrix Perform perspective correction to obtain a corrected second image (step 1044). Specifically, the corrected first image and the second image both contain the same reference background object (for example, the aforementioned transparent plate), and the corrected first image should be a front view image, so it can be based on the corrected first image The relationship with the second image, and the second homography matrix between the two is obtained. Then, according to the second homography matrix, perspective correction is performed on the second image to obtain the corrected second image. As mentioned above, the corrected second image is a front view showing the second side of the drug blister package. According to a specific embodiment of the present disclosure, after correction, the relative position of the second surface of the drug blister package in the corrected second image is the same as the relative position of the first surface in the corrected first image.

值得一提的是,可以同時或依序進行第一影像與第二影像的影像糾正程序,只要最終可分別獲得糾正後第一影像與糾正後第二影像即可。非必要性地,若第一影像已經呈現正視影像狀態時,則可僅對第二影像進行影像糾正步驟(亦即步驟1042及1044)。It is worth mentioning that the image correction procedures of the first image and the second image can be performed simultaneously or sequentially, as long as the corrected first image and the corrected second image can be obtained separately. Optionally, if the first image is already in the front-viewing image state, only the image correction step (that is, steps 1042 and 1044) can be performed on the second image.

當得到糾正後第一影像與糾正後第二影像之後,為了使該影像具有固定規格與格式,將糾正後第一影像及糾正後第二影像進行規整,以產生一合併影像(如第1圖步驟106所示)。此步驟主要是為了增進後續機器學習程序對外觀辨識的精確度,而對一影像進行處理及醒目化,藉以給出具有預定特徵(例如固定在預定的像素尺寸等)的一乾淨影像,且較佳是在乾淨影像中,移除非主體(即,藥物泡型包裝的影像)的背景部分。After the corrected first image and the corrected second image are obtained, in order to make the image have a fixed specification and format, the corrected first image and the corrected second image are normalized to generate a combined image (as shown in Figure 1). Step 106). This step is mainly to improve the accuracy of the appearance recognition of the subsequent machine learning program, and to process and highlight an image, so as to provide a clean image with predetermined characteristics (for example, fixed at a predetermined pixel size, etc.), and more It is better to remove the background part of the non-subject (ie, the image of the drug blister pack) in the clean image.

根據本揭示內容較佳實施方式,前述合併影像具體是同時呈現藥物泡型包裝的正面與反面,且原本糾正後第一影像與糾正後第二影像中,移除非藥物泡型包裝的其餘背景部分。According to a preferred embodiment of the present disclosure, the aforementioned combined image specifically presents both the front and the back of the drug blister package, and in the original corrected first image and the corrected second image, the rest of the background of the non-drug blister package is removed section.

根據本揭示內容一特定實施方式,具體規整步驟106通常包含下列步驟: (1061) 提取前述糾正後第一影像及糾正後第二影像中,藥物泡型包裝第一面及第二面之輪廓,以分別產生第一輪廓影像及第二輪廓影像; (1063) 識別第一輪廓影像及第二輪廓影像中各輪廓的角點,以確定該角點之座標; (1065) 根據步驟(1063)之座標,旋轉步驟(1061)之第一輪廓影像及第二輪廓影像,以分別形成第一處理影像及第二處理影像;以及 (1067) 規整步驟(1065)之第一處理影像及第二處理影像,以產生本揭示內容的合併影像。 According to a specific implementation of the present disclosure, the specific regularization step 106 usually includes the following steps: (1061) extracting the contours of the first side and the second side of the drug blister package from the first image after correction and the second image after correction to generate the first contour image and the second contour image respectively; (1063) Identify the corner points of each contour in the first contour image and the second contour image to determine the coordinates of the corner points; (1065) According to the coordinates of step (1063), rotate the first contour image and the second contour image of step (1061) to form a first processed image and a second processed image, respectively; and (1067) The first processed image and the second processed image of the normalizing step (1065) are generated to generate a merged image of the present disclosure.

步驟1061利用一影像處理器分別處理所述糾正後第一影像及糾正後第二影像,目的是提取出該些影像中藥物泡型包裝第一面與第二面的輪廓,以產生分別具有明確定義之輪廓的第一輪廓影像及第二輪廓影像。影像處理器執行數種演算法,以消除影像的背景雜訊並提取目標特徵。具體來說,步驟1061的提取影像係透過以下影像處理:(i)灰階轉換處理、(ii)雜訊濾除處理、(iii)邊緣識別處理、(iv)凸包(convex hull)運算處理以及(v)尋找輪廓處理。須注意的是,可獨立地以任何順序執行前述(i)至(v)各處理,較佳是以(i)至(v)之順序進行。In step 1061, an image processor is used to process the corrected first image and the corrected second image respectively, with the purpose of extracting the contours of the first side and the second side of the drug blister package in the images, so as to generate a clear image. The first contour image and the second contour image of the defined contour. The image processor executes several algorithms to eliminate the background noise of the image and extract target features. Specifically, the extracted image in step 1061 is processed through the following image processing: (i) gray-scale conversion processing, (ii) noise filtering processing, (iii) edge recognition processing, (iv) convex hull calculation processing And (v) Find contour processing. It should be noted that the aforementioned processes (i) to (v) can be performed independently in any order, preferably in the order of (i) to (v).

具體來說,(i)使用色彩轉換演算法執行灰階轉換處理,以將BGR色彩(彩色)轉換成灰階;(ii)使用過濾器演算法執行雜訊濾除處理,以將背景雜訊減至最少;(iii)使用邊緣識別演算法執行邊緣識別處理,以測定影像中藥物泡型包裝之各邊緣的座標;(iv)使用凸包運算演算法(一種用來在平面或其他低維度找到有限點集合(set of points)之凸包的演算法)執行凸包運算處理,以計算影像中藥物泡型包裝的實際面積;以及(v)使用輪廓定義演算法執行尋找輪廓處理,以提取及醒目化藥物泡型包裝的主要區域。藉由執行前述(i)至(v)各處理,從糾正後第一影像及糾正後第二影像產生各具有經定義輪廓的第一輪廓影像及第二輪廓影像,其中,背景雜訊均被消除,且該泡型包裝的主要部分被提取並醒目化,以利後續影像處理程序。Specifically, (i) use a color conversion algorithm to perform grayscale conversion processing to convert BGR colors (color) into grayscale; (ii) use a filter algorithm to perform noise filtering processing to remove background noise Minimize; (iii) use edge recognition algorithms to perform edge recognition processing to determine the coordinates of each edge of the drug blister package in the image; (iv) use convex hull algorithm (a type used in flat or other low-dimensional Find the convex hull algorithm of a finite set of points) perform the convex hull calculation process to calculate the actual area of the drug blister package in the image; and (v) use the contour definition algorithm to perform the contour finding process to extract And the main area of eye-catching drug blister packaging. By performing the aforementioned processes (i) to (v), a first contour image and a second contour image each with a defined contour are generated from the corrected first image and the corrected second image, wherein the background noise is Elimination, and the main part of the blister packaging is extracted and eye-catching to facilitate subsequent image processing procedures.

續行步驟1063,該步驟係定義出第一輪廓影像與第二輪廓影像中各輪廓的角點。不論藥物之泡型包裝的輪廓形狀為何,此步驟可確定每一張輪廓影像的至少一角點之座標。較佳地,確定從步驟1061獲取的第一輪廓影像與第二輪廓影像的四個角點座標。此步驟的目標在於從藥物泡型包裝的輪廓邊緣預測出至少三條直線,接著透過幾何學推理方式以獲得最貼近泡型包裝邊緣的四邊形以及各角點相對於平面座標系上的座標。由於泡型包裝可能具有多種形狀及/或輪廓,因此,可採用不同演算法來從第一輪廓影像及第二輪廓影像中識別角點。舉例來說,若前述輪廓影像中的藥物泡型包裝的輪廓形狀是常規的四邊形(如:矩形),則可採用直線轉換演算法來識別四個角點,進而確立該該角點的座標。另一方面,若該些輪廓影像中藥物泡型包裝的輪廓形狀是非常規四邊形,像是具有三個直線邊緣及一個曲線邊緣的非典型多邊形,那麼則採用質心演算法來進行角點識別。透過前述設計,不論藥物包裝的方向及形狀為何,均能確定每個角點的座標。Step 1063 is continued, which defines the corner points of each contour in the first contour image and the second contour image. Regardless of the outline shape of the drug blister package, this step can determine the coordinates of at least one corner of each outline image. Preferably, the coordinates of the four corner points of the first contour image and the second contour image obtained from step 1061 are determined. The goal of this step is to predict at least three straight lines from the contour edge of the drug blister package, and then use geometric inference to obtain the quadrilateral closest to the blister package edge and the coordinates of each corner point relative to the plane coordinate system. Since the blister package may have multiple shapes and/or contours, different algorithms can be used to identify corner points from the first contour image and the second contour image. For example, if the outline shape of the drug blister package in the outline image is a conventional quadrilateral (such as a rectangle), a straight-line conversion algorithm can be used to identify the four corner points, and then establish the coordinates of the corner points. On the other hand, if the outline shape of the drug blister package in the outline images is an unconventional quadrilateral, such as an atypical polygon with three straight edges and one curved edge, then the centroid algorithm is used for corner recognition. Through the aforementioned design, regardless of the direction and shape of the drug package, the coordinates of each corner can be determined.

於步驟1063中,識別每一處理影像的角點不僅是為了建立後續旋轉步驟(1065)及規整步驟(1067)的定錨點,同時也是為了確保整個藥物泡型包裝有被包含在第一輪廓影像與第二輪廓影像中以便後續分析。值得注意的是,前述泡型包裝輪廓經確定的四個角點的座標必須以順時針或逆時針方式排列,據此可基於該四個角點的確定座標將第一輪廓影像及第二輪廓影像旋轉至一預定的位置(步驟1065),以分別形成第一處理影像及第二處理影像。預定的位置可隨著實際實施需求變化。在某些實施例中,預定位置是指藥物泡型包裝的短邊與長邊分別與平面座標系統的X軸及Y軸平行。泡型包裝較佳的定向方式是僅需旋轉一次影像就可使其短邊與長邊分別與笛卡兒座標系統的X軸及Y軸平行。實際施用時,可使用多種透視轉換演算法旋轉第一輪廓影像及第二輪廓影像,其設有預定像素尺寸(例如 448×224像素),藉以分別產生有預定位置的第一處理影像及第二處理影像。In step 1063, identifying the corner points of each processed image is not only to establish anchor points for the subsequent rotation step (1065) and regularization step (1067), but also to ensure that the entire drug blister package is contained in the first outline Image and the second contour image for subsequent analysis. It is worth noting that the coordinates of the four corner points determined for the aforementioned blister package outline must be arranged in a clockwise or counterclockwise manner. According to this, the first outline image and the second outline can be combined based on the determined coordinates of the four corner points. The image is rotated to a predetermined position (step 1065) to form a first processed image and a second processed image respectively. The predetermined location can vary with actual implementation requirements. In some embodiments, the predetermined position means that the short side and the long side of the drug blister package are respectively parallel to the X axis and the Y axis of the plane coordinate system. The better orientation method for blister packaging is to rotate the image only once to make the short and long sides parallel to the X and Y axes of the Cartesian coordinate system, respectively. In actual application, a variety of perspective conversion algorithms can be used to rotate the first contour image and the second contour image, which have a predetermined pixel size (for example, 448×224 pixels), so as to generate the first processed image and the second processed image with predetermined positions, respectively. Process images.

接著,在步驟1067,將前述步驟所得之第一處理影像及第二處理影像並排放置,進行規整以產生一合併影像。應注意的是從此步驟獲得的合併影像可包含數種組合,這有利於盡可能地建立藥物資料庫數據。第一處理影像及第二處理影像可以分別呈現正立或倒立狀態。較佳地,是相同方向且分別呈現藥物泡型包裝正反兩面的第一及第二處理影像彼此規整,以產生一次性包含該藥物泡型包裝最多特徵資訊的合併影像。Next, in step 1067, the first processed image and the second processed image obtained in the foregoing steps are placed side by side and regularized to generate a combined image. It should be noted that the merged image obtained from this step can contain several combinations, which is helpful for establishing the drug database data as much as possible. The first processed image and the second processed image can be in an upright or inverted state, respectively. Preferably, the first and second processed images that are in the same direction and respectively present the front and back sides of the drug blister package are aligned with each other to generate a merged image that contains the most characteristic information of the drug blister package at one time.

繼續參考第1圖,為了建立藥物資料庫,在步驟108及110中,將合併影像用於訓練嵌入計算機的機器學習演算法,以產生參考影像。包含藥物資訊的合併影像是以儲存在藥物資料庫的參考影像來分類,且之後可讀取用於識別候選包裝。在某些實施方式中,可將多種藥物之至少一合併影像輸入至機器學習演算法中。在例示性實施方式,可將超過10至20,000張的合併影像,例如10、100、200、300、400、500、1000、1,100、1,200、1,300、1,400、1,500、2,000、2,500、3,000、3,500、4,000、4,500、5,000、5,500、10,000、11,000、12,000、13,000、14,000、15,000、16,000、17,000、18,000、19,000及20,000張合併影像輸入至機器學習演算法,以建立藥物資料庫。每張影像可用於訓練機器學習系統以將該影像資訊轉換成參考資訊,接著可將該參考資訊儲存在裝置及/或系統內建的資料庫中。Continuing to refer to Figure 1, in order to build a drug database, in steps 108 and 110, the combined images are used to train the machine learning algorithm embedded in the computer to generate reference images. The combined images containing drug information are classified based on the reference images stored in the drug database, and can be read later to identify candidate packages. In some embodiments, at least one combined image of multiple drugs can be input into a machine learning algorithm. In an exemplary embodiment, more than 10 to 20,000 combined images can be combined, such as 10, 100, 200, 300, 400, 500, 1000, 1,100, 1,200, 1,300, 1,400, 1,500, 2,000, 2,500, 3,000, 3,500, 4,000, 4,500, 5,000, 5,500, 10,000, 11,000, 12,000, 13,000, 14,000, 15,000, 16,000, 17,000, 18,000, 19,000, and 20,000 combined images are input to machine learning algorithms to build a drug database. Each image can be used to train the machine learning system to convert the image information into reference information, which can then be stored in the device and/or the built-in database of the system.

須注意的是,適用於本揭示內容的機器學習程式系統可以是任何本技術領域習知的視覺對象偵測模型,根據實際需要在某些準則下優化或不優化,該些模型包含但不限於:可變型組件模型(formable parts model,DPM)、區域卷積神經網路(region convolutional neural network,R-CNN)、快速區域卷積神經網路(Fast R-CNN)、高速區域卷積神經網路(Faster R-CNN)、遮罩區域卷積神經網路(mask R-CNN)以及YOLO。較佳地,對適用於訓練本揭示內容之學習步驟的視覺對象偵測模型進行優化,至少對參數(像是輸入的影像像素、定界框(bounding box)及錨框(anchor box)的數目和尺寸)進行優化。根據本揭示內容,經前述步驟處理且後續輸入至學習系統的合併影像應為符合預定尺寸(例如固定像素)的「滿版影像」(full bleed image)。因此,錨框的數目及尺寸可被最小化(例如最小化至僅有一個錨框),以增進計算速度與效能。換言之,藉由上述取得正視影像,並將兩張正視影像規整成一張的步驟,使得機器學習系統在處理大規模藥物包裝的大量數據時,也能順暢快速地運行。更甚者,可縮短整體處理時間,這大幅地增進建立藥物資料庫的效能。It should be noted that the machine learning program system suitable for the present disclosure can be any conventional visual object detection model in the technical field, which is optimized or not optimized under certain criteria according to actual needs. These models include but are not limited to : Formable parts model (DPM), region convolutional neural network (R-CNN), fast region convolutional neural network (Fast R-CNN), high-speed regional convolutional neural network Road (Faster R-CNN), masked area convolutional neural network (mask R-CNN) and YOLO. Preferably, the visual object detection model suitable for training the learning step of the present disclosure is optimized, and at least the parameters (such as the number of input image pixels, bounding boxes and anchor boxes) are optimized. And size) for optimization. According to the present disclosure, the merged image processed by the foregoing steps and subsequently input to the learning system should be a "full bleed image" that meets a predetermined size (for example, a fixed pixel). Therefore, the number and size of anchor frames can be minimized (for example, to only one anchor frame) to improve calculation speed and performance. In other words, through the above-mentioned steps of obtaining the front-view images and arranging the two front-view images into one, the machine learning system can also run smoothly and quickly when processing large amounts of data on large-scale drug packaging. What's more, the overall processing time can be shortened, which greatly improves the efficiency of establishing a drug database.

另,本文所述之標的可以使用儲存有處理器可讀取指令的非暫時、有形的處理器可讀取儲存媒體來實施。當受到一可程式化裝置的處理器執行時,所述指令可控制該可程式化裝置以執行根據本揭示內容實施方式的方法。適用於實現本文所述之標的的例示性處理器可讀取儲存媒體可包含(但不限於)RAM、ROM、EPROM、EEPROM、快閃記憶體或其他故態記憶體技術:CD-ROM、DVD或其他光儲存、磁卡式、磁碟儲存或其他磁性儲存裝置,以及其他可用於儲存所需資訊且可由處理器讀取的媒體。此外,實現本發明標的之處理器可讀取儲存媒體可以位於單一裝置或計算平台上,或者也可分佈在多個裝置或計算平台上。在某些實施方式中,計算平台是具有實時計算約束的嵌入式系統。In addition, the subject matter described herein can be implemented using a non-transitory, tangible processor-readable storage medium storing processor-readable instructions. When executed by a processor of a programmable device, the instructions can control the programmable device to execute the method according to the embodiment of the present disclosure. Exemplary processor-readable storage media suitable for implementing the subject matter described herein may include (but are not limited to) RAM, ROM, EPROM, EEPROM, flash memory, or other stale memory technologies: CD-ROM, DVD, or Other optical storage, magnetic card type, magnetic disk storage or other magnetic storage devices, and other media that can be used to store the required information and that can be read by the processor. In addition, the processor-readable storage medium that implements the subject of the present invention may be located on a single device or computing platform, or may also be distributed on multiple devices or computing platforms. In some embodiments, the computing platform is an embedded system with real-time computing constraints.

本揭示內容經處理及醒目化的影像,並藉由將兩張處理影像規整成一張的「合併影像」,實際上增加計算效能與準確度。藉由上述技術特徵,本揭示內容目的在於透過藥物泡型包裝影像所建立的藥物資料庫,並根據該藥物資料庫作為識別藥物之基準,可以於配藥過程增進藥物識別的準確度並消除人為疏失,藉此改善藥物使用安全及病患照護的品質。The processed and eye-catching images of the present disclosure, and by arranging the two processed images into a "merged image", actually increase the calculation performance and accuracy. Based on the above technical features, the purpose of this disclosure is to establish a drug database based on drug blister packaging images, and use the drug database as a benchmark for drug identification, which can improve the accuracy of drug identification and eliminate human error during the dispensing process. , To improve the safety of drug use and the quality of patient care.

2.2. 藥物管理系統Drug Management System

本發明標的之另一個態樣是提供一藥物管理系統。參考繪示藥物管理系統200之第2圖,藥物管理系統200包含一影像擷取裝置210、一影像處理器220、一藥物資料庫230以及一機器學習處理器240,其中該影像擷取裝置210及機器學習處理器240分別耦合至該影像處理器220,而該藥物資料庫230係以通訊式或實體與機器學習處理器240連接。Another aspect of the subject of the present invention is to provide a drug management system. Referring to FIG. 2 of the medication management system 200, the medication management system 200 includes an image capture device 210, an image processor 220, a drug database 230, and a machine learning processor 240, wherein the image capture device 210 The machine learning processor 240 and the machine learning processor 240 are respectively coupled to the image processor 220, and the medicine database 230 is connected to the machine learning processor 240 in a communication mode or physically.

影像擷取裝置210設以擷取一藥物之泡型包裝的一或多個影像。在某些實施方式中,影像擷取裝置210其結構包含有一透明板體211以及分別設置在該透明板體211兩側的第一影像擷取單元213與第二影像擷取單元215。該透明板體211可以是由玻璃或丙烯酸聚合物製成。具體來說,第一影像擷取單元213設置在透明板體211的上側(如第2圖),以第一角度θ擷取一藥物的第一影像,其中該第一影像包含藥物泡型包裝的第一面(例如正面);第二影像擷取單元215設置在透明板體211的下側,以第二角度擷取該藥物的第二影像,第二影像包含藥物泡型包裝的第二面(例如反面)。在特定實施方式中,第一角度及第二角度是第一影像擷取單元213與第二影像擷取單元215分別相對於該透明板體211之水平面為40至90度,例如:40、45、50、55、60、65、70、75、80、85或90度。在實施上,藥物放置在透明板體211上,第一影像擷取單元213以45至60度之俯角對藥物進行影像擷取,較佳為50度。另一方面,第二影像擷取單元215則以仰角90度從透明板體211下方朝上,對藥物進行影像擷取(如第2圖所示)。較佳地,第一影像擷取單元213與第二影像擷取單元215是同時擷取該藥物泡型包裝的正反面影像。舉例來說,第一影像擷取單元213與第二影像擷取單元215是實時數位相機。The image capturing device 210 is configured to capture one or more images of a blister pack of a medicine. In some embodiments, the structure of the image capturing device 210 includes a transparent board 211 and a first image capturing unit 213 and a second image capturing unit 215 respectively disposed on both sides of the transparent board 211. The transparent plate 211 may be made of glass or acrylic polymer. Specifically, the first image capturing unit 213 is disposed on the upper side of the transparent plate 211 (as shown in FIG. 2), and captures a first image of a drug at a first angle θ, wherein the first image includes a drug blister package The second image capturing unit 215 is arranged on the lower side of the transparent plate 211 to capture a second image of the drug at a second angle, and the second image includes the second image of the drug blister package. Face (for example, the reverse). In a specific embodiment, the first angle and the second angle are 40 to 90 degrees of the first image capturing unit 213 and the second image capturing unit 215 relative to the horizontal plane of the transparent plate 211, for example: 40, 45 , 50, 55, 60, 65, 70, 75, 80, 85 or 90 degrees. In practice, the medicine is placed on the transparent plate 211, and the first image capturing unit 213 captures images of the medicine at a depression angle of 45 to 60 degrees, preferably 50 degrees. On the other hand, the second image capturing unit 215 performs image capturing of the medicine from below the transparent plate body 211 at an elevation angle of 90 degrees (as shown in FIG. 2). Preferably, the first image capturing unit 213 and the second image capturing unit 215 capture the front and back images of the drug blister package at the same time. For example, the first image capturing unit 213 and the second image capturing unit 215 are real-time digital cameras.

除非另有說明,根據本揭示內容,影像處理器220及機器學習處理器240分別包含用於儲存複數個指令的記憶體,該些指令可使處理器實現本發明的方法,包含前述態樣建立藥物資料庫230的方法以及本態樣識別藥物的方法。在某些實施方式中,是將影像處理器220及機器學習處理器240設成兩個獨立的裝置;或者也可將兩者設置在相同硬體中。在某些實施方式中,影像處理器220及機器學習處理器240是可通訊式彼此連接。具體而言,影像處理器220是可通訊式與影像擷取裝置210連接,以接受經由該影像擷取裝置210擷取的影像,並設以執行本發明第一電腦實施方法的影像處理步驟(亦即前述步驟104及106),據此產生用於建立藥物資料庫230的合併影像及/或用於後續識別的候選影像。本發明經前述方法100建立之藥物資料庫230,可以儲存在透過電纜連接或無線網路與機器學習處理器240相連的儲存裝置中以提供一參考影像,或是非必要地,將藥物資料庫230是儲存於機器學習處理器240中。在第2圖描述的例示性實施方式中,本發明藥物資料庫230係以通訊式與機器學習處理器240連接。機器學習處理器240還可通訊式與影像處理器220連接,並設以實現本發明第二電腦實施方法之影像比對,以用於藥物識別。此方法包含將候選影像與以本發明前述方法100所建立之藥物資料庫230中的參考影像進行比對。Unless otherwise specified, according to the present disclosure, the image processor 220 and the machine learning processor 240 each include a memory for storing a plurality of instructions, which can enable the processor to implement the method of the present invention, including the aforementioned configuration The method of drug database 230 and the method of identifying drugs in this aspect. In some embodiments, the image processor 220 and the machine learning processor 240 are set as two independent devices; or the two may also be set in the same hardware. In some embodiments, the image processor 220 and the machine learning processor 240 are communicably connected to each other. Specifically, the image processor 220 is communicatively connected with the image capture device 210 to receive images captured by the image capture device 210, and is configured to execute the image processing steps of the first computer implementation method of the present invention ( That is, the aforementioned steps 104 and 106) are used to generate merged images for building the drug database 230 and/or candidate images for subsequent identification. The drug database 230 established by the aforementioned method 100 of the present invention can be stored in a storage device connected to the machine learning processor 240 through a cable connection or a wireless network to provide a reference image, or optionally, the drug database 230 It is stored in the machine learning processor 240. In the exemplary embodiment described in FIG. 2, the drug database 230 of the present invention is connected to the machine learning processor 240 in a communication mode. The machine learning processor 240 can also be communicatively connected with the image processor 220 and configured to implement the image comparison of the second computer-implemented method of the present invention for drug identification. The method includes comparing the candidate image with the reference image in the drug database 230 established by the method 100 of the present invention.

在某些實施方式中,藥物管理系統200更包含一使用者介面(未示出),設以輸出藥物識別結果、接受來自外部使用者之指令、以及將使用者輸入反饋至影像處理器220及機器學習處理器240。In some embodiments, the medication management system 200 further includes a user interface (not shown) for outputting medication identification results, accepting instructions from external users, and feeding user input to the image processor 220 and Machine learning processor 240.

可使用各種技術實施影像擷取裝置210、影像處理器220、藥物資料庫230及影像學習處理器240之間的通訊。舉例來說,本發明藥物管理系統200可包含一網路介面以允許影像擷取裝置210、影像處理器220、藥物資料庫230以及機器學習處理器240之間通過網路(例如一區域通信網路(LAN)、一廣域網路(WAN)、網路或無線網路)來通訊。在其他實施例中,該系統可具有一系統匯流排(system bus),其耦合各種系統組件(包含影像擷取裝置210)至該影像處理器220。Various technologies can be used to implement the communication between the image capture device 210, the image processor 220, the medicine database 230, and the image learning processor 240. For example, the medication management system 200 of the present invention may include a network interface to allow the image capturing device 210, the image processor 220, the medication database 230, and the machine learning processor 240 to communicate through a network (such as a local area communication network). Communication via LAN, a wide area network (WAN), network or wireless network). In other embodiments, the system may have a system bus, which couples various system components (including the image capture device 210) to the image processor 220.

下文提出多個實施例來說明本發明的某些態樣,以利本發明所屬技術領域中具有通常知識者實作本發明。不應將這些實驗例視為對本發明範圍的限制。無須進一步說明,據信所屬技術領域中具有通常知識者可根據本文的描述,最大限度地利用本發明。本文引用的所有公開文獻均透過引用其整體併入本文。A number of embodiments are presented below to illustrate certain aspects of the present invention, so as to facilitate those skilled in the art to which the present invention belongs to implement the present invention. These experimental examples should not be regarded as limiting the scope of the present invention. Without further explanation, it is believed that those with ordinary knowledge in the technical field can use the present invention to the fullest extent based on the description herein. All publications cited herein are incorporated herein by reference in their entirety.

實施例1:構建藥物資料庫Example 1: Construction of a drug database

對初始拍攝影像進行影像糾正的策略Strategies for image correction of the initial shot image

從馬偕紀念醫院(臺北,臺灣)醫院藥房收集市售現有的250多種藥物。為了構建藥物資料庫的數據庫,盡可能地取得所有藥物泡型包裝的照片。在進行影像擷取時,隨機選擇一藥物放置在配備有玻璃製成之透明板體的特製櫃體上,不限該藥物放置的具體位置。設置圍繞透明板體的光源以利照明,並將兩個BRIO網路攝影機 (Logitech, USA)個別設置在透明板體的兩側(與板體保持一距離),確保該網路攝影機的視野能涵蓋整個板體區域。其中,設置於上方的網路攝影機相對於透明板體平面具有一50度之俯角;設置於下方的網路攝影機則垂直向上方拍攝。在攝得影像非正視視野影像的情況下,利用影像糾正的概念對所拍攝的影像進行糾正。Collect more than 250 kinds of drugs currently on the market from the hospital pharmacy of Mackay Memorial Hospital (Taipei, Taiwan). In order to build a database of the drug database, as much as possible to obtain photos of all drug blister packaging. When performing image capture, a drug is randomly selected and placed on a special cabinet equipped with a transparent plate made of glass, and the specific location of the drug is not limited. Set up a light source around the transparent board to facilitate lighting, and install two BRIO webcams (Logitech, USA) on both sides of the transparent board (keep a distance from the board) to ensure the field of vision of the webcam Cover the entire board area. Among them, the web camera located above has a depression angle of 50 degrees with respect to the plane of the transparent plate; the web camera located below shoots vertically upwards. In the case where the captured image is not a front-view image, the concept of image correction is used to correct the captured image.

第3圖例示性地呈現如何將藥物泡型包裝之第一影像及第二影像分別糾正為糾正後第一影像及糾正後第二影像。如第3圖所示,首先定義攝於透明板體上方之攝影機為

Figure 02_image001
,其斜向水平的玻璃板體,所拍攝的第一影像為
Figure 02_image003
,通常包含藥物泡型包裝的正面;另假設一虛擬垂直正上方攝影機
Figure 02_image005
,假定該虛擬攝影機
Figure 02_image005
所拍攝的虛擬影像為
Figure 02_image007
,應呈現與第一影像
Figure 02_image003
相近視野的正視視角。下方攝影機
Figure 02_image009
,由
Figure 02_image009
所拍攝的第二影像為
Figure 02_image011
,通常是藥物泡型包裝的反面。第一影像
Figure 02_image003
及第二影像
Figure 02_image011
經影像糾正之後,分別以
Figure 02_image013
Figure 02_image015
表示。 Figure 3 exemplarily shows how to correct the first image and the second image of the drug blister package into the corrected first image and the corrected second image, respectively. As shown in Figure 3, first define the camera taken above the transparent plate as
Figure 02_image001
, Its obliquely horizontal glass plate, the first image taken is
Figure 02_image003
, Usually contains the front of the drug blister package; also assume a virtual vertical camera directly above
Figure 02_image005
, Assuming that the virtual camera
Figure 02_image005
The virtual image taken is
Figure 02_image007
, Should be presented with the first image
Figure 02_image003
The frontal angle of view of the similar field of view. Camera below
Figure 02_image009
,by
Figure 02_image009
The second image taken is
Figure 02_image011
, Usually the opposite of drug blister packaging. First image
Figure 02_image003
And the second image
Figure 02_image011
After image correction,
Figure 02_image013
versus
Figure 02_image015
Said.

首先在虛擬影像

Figure 02_image007
與第一影像
Figure 02_image003
之間尋找一第一單應性矩陣
Figure 02_image017
,具體方法是根據玻璃透明板體的實際長寬比例,在虛擬影像
Figure 02_image007
及第一影像
Figure 02_image003
中分別定義出可互相對應的各四個角點(例如第3圖,第一影像
Figure 02_image003
中的四個圓點)。具體可以定義位於虛擬影像
Figure 02_image007
正中間一玻璃的四個角點,同時第一影像
Figure 02_image003
也具有該矩形的對應四個角點,進而求得
Figure 02_image017
。求得虛擬影像
Figure 02_image007
與第一影像
Figure 02_image003
之間的第一單應性矩陣
Figure 02_image017
之後,將第一影像
Figure 02_image003
與第一單應性矩陣
Figure 02_image017
相乘則可得到糾正後第一影像
Figure 02_image013
。 First in the virtual image
Figure 02_image007
With the first image
Figure 02_image003
Find a first homography matrix
Figure 02_image017
, The specific method is based on the actual aspect ratio of the transparent glass plate, in the virtual image
Figure 02_image007
And the first image
Figure 02_image003
Define the four corner points that can correspond to each other (for example, Figure 3, the first image
Figure 02_image003
Four dots in). It can be defined in the virtual image
Figure 02_image007
The four corners of the glass in the middle, and the first image
Figure 02_image003
It also has the corresponding four corners of the rectangle, and then obtains
Figure 02_image017
. Get a virtual image
Figure 02_image007
With the first image
Figure 02_image003
The first homography matrix between
Figure 02_image017
After that, the first image
Figure 02_image003
With the first homography matrix
Figure 02_image017
Multiply to get the first image after correction
Figure 02_image013
.

接著,求得糾正後第一影像

Figure 02_image013
之後,還可以利用在虛擬影像
Figure 02_image007
正中間呈現的玻璃四個角點(其與糾正後第一影像
Figure 02_image013
中玻璃四個角點同)與第二影像
Figure 02_image019
之間的對應關係,求得
Figure 02_image021
,並將
Figure 02_image011
乘上
Figure 02_image021
後得到糾正後第二影像
Figure 02_image015
。由於糾正後第二影像
Figure 02_image015
追本溯源仍是從上方正視虛擬影像
Figure 02_image007
得來,因此可知道糾正後第二影像
Figure 02_image015
中,藥物泡型包裝反面影像出現的相對位置與糾正後第一影像
Figure 02_image013
中藥物泡型包裝正面影像的相對位置相同(如第3圖所示)。 Then, get the first image after correction
Figure 02_image013
Later, you can also use the virtual image
Figure 02_image007
The four corners of the glass appearing in the middle (the same as the first image after correction)
Figure 02_image013
The four corners of the middle glass are the same) and the second image
Figure 02_image019
Correspondence between, find
Figure 02_image021
And will
Figure 02_image011
ride on
Figure 02_image021
After being corrected, the second image
Figure 02_image015
. Since the second image after correction
Figure 02_image015
Tracing back to the source is still looking at the virtual image from above
Figure 02_image007
So we know that the second image after correction
Figure 02_image015
In, the relative position of the reverse image of the drug blister package and the first image after correction
Figure 02_image013
The relative position of the front image of the traditional Chinese medicine blister package is the same (as shown in Figure 3).

製備糾正雙面影像Prepare and correct double-sided images (Rectified Two-sided Images(Rectified Two-sided Images , RTIs)RTIs)

得到糾正後第一影像

Figure 02_image013
及糾正後第二影像
Figure 02_image015
後,利用編程在影像處理器中的開發函式庫(Open Source Computer Vision 2,OpenCV 2)函式,對各影像進行裁剪以最小化背景雜訊並對其進行處理,以產生去背景之藥物泡型包裝正面輪廓影像
Figure 02_image023
及去背景之藥物泡型包裝反面輪廓影像
Figure 02_image025
。除了從糾正後第二影像
Figure 02_image015
進行提取去背來獲得藥物泡型包裝反面輪廓影像
Figure 02_image025
之外,由於糾正後第一影像
Figure 02_image013
可視為虛擬影像
Figure 02_image007
,因此也可以透過對去背景之藥物泡型包裝正面輪廓影像
Figure 02_image023
直接乘上
Figure 02_image021
,來產生去背景之藥物泡型包裝反面輪廓影像
Figure 02_image025
。接著將去背景之藥物泡型包裝正面輪廓影像
Figure 02_image023
及去背景之藥物泡型包裝反面輪廓影像
Figure 02_image025
經旋轉後,規整產生合併影像(本發明稱為『校正雙面併整影像(RTIs)』)。每個RTI可與一預定模板(以下稱為校正雙面併整模板(rectified two-sided template,RTT)適配並且包含一藥物泡型包裝的正面與反面。預定模板是指規整合併影像成448 × 224像素之尺寸。總共取得18,000的RTIs,並利用CNN模型進行後續深度學習處理程序。 The first image after being corrected
Figure 02_image013
And corrected second image
Figure 02_image015
Then, use the Open Source Computer Vision 2 (OpenCV 2) function programmed in the image processor to crop each image to minimize the background noise and process it to produce a background-removing medicine Front profile image of blister packaging
Figure 02_image023
And the back profile image of the drug blister package with the background removed
Figure 02_image025
. Except from the corrected second image
Figure 02_image015
Perform extraction to get back contour image of drug blister package
Figure 02_image025
In addition, because the first image after correction
Figure 02_image013
Can be regarded as a virtual image
Figure 02_image007
, So you can also image the front profile of the drug blister pack with the background removed
Figure 02_image023
Multiply directly
Figure 02_image021
, To produce the back profile image of the drug blister pack without background
Figure 02_image025
. Next, the front profile image of the drug blister package with the background removed
Figure 02_image023
And the back profile image of the drug blister package with the background removed
Figure 02_image025
After being rotated, a combined image is generated in a regular manner (this invention is called "corrected double-sided combined image (RTIs)"). Each RTI can be adapted to a predetermined template (hereinafter referred to as a rectified two-sided template (RTT)) and includes the front and back sides of a drug blister package. The predetermined template refers to the integration and image formation of 448 × 224 pixels in size. A total of 18,000 RTIs are obtained, and the CNN model is used for subsequent deep learning processing procedures.

偵測藥物泡型包裝之不規則四邊形角點的策略Strategies for detecting irregular quadrilateral corners of drug blister packaging

承前所述,為了對去背景之藥物泡型包裝影像

Figure 02_image023
Figure 02_image025
進行旋轉,需偵測藥物泡型包裝輪廓的各角點。在待測藥物泡型包裝具有三直線邊緣及一曲線邊緣構成的不規則四邊形形狀之情況下,利用質心算法(表1)透過幾何學推理以測定曲線邊緣和未定義角點。 表1:用於偵測不規則四邊形形狀角點的質心演算法 輸入:三條邊緣線 L以及泡型包裝的輪廓形狀資訊 blisterContour輸出:透過直線交點以及幾何學推理找到的四個角點 P 1 P 2 P 3 P 4 (以循環順序排列) 1: 程序 FINDCORNERS( L, blisterContour) 2:   P 1, P 4 ← 三條線 L的兩個交點。 3:   M ← 兩交點 P 1 、P 4 之間的中點。 4:   B ← 泡型包裝輪廓形狀的質心 blisterContour。 5:  
Figure 02_image027
← 從 MB的位移向量。 6:    P 2 P 1 + 2
Figure 02_image027
7:   P 3 P 4 + 2
Figure 02_image027
As mentioned above, in order to image the drug blister packaging with the background removed
Figure 02_image023
and
Figure 02_image025
To rotate, it is necessary to detect the corner points of the outline of the drug blister package. When the drug blister package to be tested has an irregular quadrilateral shape composed of three straight edges and a curved edge, the centroid algorithm (Table 1) is used to determine the curved edges and undefined corners through geometric inference. Table 1: Centroid algorithm for detecting corners of irregular quadrilateral shapes Input: Three edge lines L and the contour shape information of the blister package blisterContour Output: Four corner points P 1 , P 2 , P 3 and P 4 (arranged in cyclic order) found through the intersection of straight lines and geometric inference 1: Program FINDCORNERS( L, blisterContour ) 2: P 1 , P 4 ← two intersection points of three lines L. 3: M ← the midpoint between two intersection points P 1 and P 4. 4: B ← the center of mass blisterContour of the contour shape of the blister package. 5:
Figure 02_image027
← The displacement vector from M to B. 6: P 2 P 1 + 2
Figure 02_image027
7: P 3 P 4 + 2
Figure 02_image027

第4圖例示性地呈現如何對具有不規則四邊形之藥物包裝執行角點識別。如第4圖所繪,具有三條直線邊緣( L 1 L 2 L 3 )及一曲線邊緣(C 1)的泡型包裝呈現隨機的方向,其中將 L 1 L 2 的交點指定為 P 1 ,而 L 2 L 3 的交點則指定為 P 4 。目標是要確定 P 2 P 3 的座標,據此四個點( P 1 P 2 P 3 P 4 )以及四個邊緣( L 1 L 2 L 3 C 1 )包圍的區域會涵蓋整個包裝的影像。首先確定 P 1 P 4 之間在邊緣 L 2 上的中點 M,接著可透過演算法cv2.moments (OpenCV 2)確定藥物泡型包裝面積的質心 B。基於中點 M及質心 B的座標計算出位移向量 v。最後可確定分別距交點 P 1 P 4 兩倍位移向量之位置便是 P 2 P 3 之座標。透過前述流程,四個交點或角點 P 1 P 2 P 3 P 4 可自動地以順時針或逆時針方向排序。 Figure 4 exemplarily shows how to perform corner point recognition on drug packages with irregular quadrilaterals. As depicted in Figure 4, a blister package with three straight edges (L 1 , L 2 , L 3 ) and a curved edge (C 1 ) presents a random direction, where the intersection of L 1 and L 2 is designated as P 1 , and the intersection of L 2 and L 3 is designated as P 4 . The goal is to determine the coordinates of P 2 and P 3 , based on the four points ( P 1 , P 2 , P 3 and P 4 ) and the area surrounded by the four edges ( L 1 , L 2 , L 3 and C 1) Will cover the image of the entire package. First, determine the midpoint M between P 1 and P 4 on the edge L 2 , and then use the algorithm cv2.moments (OpenCV 2) to determine the center of mass B of the drug blister packaging area. The displacement vector v is calculated based on the coordinates of the midpoint M and the center of mass B. Finally, it can be determined that the positions twice the displacement vector from the intersection points P 1 and P 4 are the coordinates of P 2 and P 3. Through the foregoing process, the four intersection points or corner points P 1 , P 2 , P 3 and P 4 can be automatically sorted in a clockwise or counterclockwise direction.

實施例2:評估基於實施例1的藥物資料庫執行機器學習的藥物管理系統的分類效率Example 2: Evaluate the classification efficiency of a medication management system that implements machine learning based on the medication database of Example 1

處理並合併影像Process and merge images

為了評估本揭示內容RTIs的視覺辨識效能,將藥物的原始影像(未處理且未合併)及RTIs(經處理並合併)分別輸入至訓練模型(經優化的Tiny YOLO)以進行深度學習。表2總結訓練結果。根據表2的數據,相較於未處理的原始影像,本揭示內容的「醒目化」影像在訓練視覺辨識方面具高效能。訓練的F1-分數越高,表示深度學習網路對包裝影像的視覺辨識的效果越好。相較於那些未經處理的影像,經處理成RTT的RTIs也顯著地增加訓練效果。 表2:未處理影像與RTIs之比較 實驗組別 組別I 組別II 組別III 影像類型 未處理影像(正面) 未處理影像(反面) 如實施例1經處理影像(RTIs) 訓練時間(分) 362 462 23 訓練型樣 65 83 5 精密度(%) 77.03 89.39 -- 召回 67.44 87.68 -- F1-分數 65.39 86.48 99.82 In order to evaluate the visual recognition performance of the RTIs of the present disclosure, the original images of the drugs (unprocessed and unmerged) and RTIs (processed and merged) are respectively input to the training model (optimized Tiny YOLO) for deep learning. Table 2 summarizes the training results. According to the data in Table 2, compared to the unprocessed original image, the “brighter” image of the present disclosure has high performance in training visual recognition. The higher the training F1-score, the better the visual recognition effect of the deep learning network on packaging images. Compared with the unprocessed images, the RTIs processed into RTT also significantly increase the training effect. Table 2: Comparison of unprocessed images and RTIs Experimental group Group I Group II Group III Image type Unprocessed image (front side) Unprocessed image (reverse side) Processed images (RTIs) as in Example 1 Training time (minutes) 362 462 twenty three Training type 65 83 5 Precision (%) 77.03 89.39 - recall 67.44 87.68 - F1-score 65.39 86.48 99.82

實時藥物識別應用Real-time drug identification application

操作時,隨機選擇一藥物放置在配備有玻璃製成之透明板體上。設置圍繞透明板體的光源以利照明,並將兩個BRIO網路攝影機 (Logitech, USA)個別設置在透明板體的兩側(與板體保持一距離),確保該網路攝影機的視野能涵蓋整個板體區域。另一方面,先將實施例1建好的藥物資料庫儲存在實時嵌入式計算裝置JETSON TMTX2 (NVIDIA, USA)中。JETSON TMTX2,稱為「開發者套件(developer kit)」,其包含記憶體、 CPU、GPU、USB埠、網形天線以及其他計算元件,藉此使影像處理步驟及機器學習步驟可在相同裝置內執行。操作上,兩個網路攝影機可透過USB電纜與 JETSON TMTX2連接,據此所選藥物的正面與反面影像可實時地同時傳送給處理器。將所選藥物泡型包裝的兩張原始影像處理成一張RTI,接著該RTI接受編程在JETSON TMTX2內的學習模型Tiny YOLO進行後續程序。 Tiny YOLO模型的視覺辨識速度可達每秒約200幀(FPS)。總流程(即,從擷取影像至視覺識別)所花費的時間約每秒6.23幀。識別結果可實時呈現在一外部顯示裝置上,例如電腦螢幕或是行動電話使用介面。因此,外部使用者幾乎可與藥物放上玻璃板體上後,同時獲得該藥物之識別結果。 During operation, a drug is randomly selected and placed on a transparent plate equipped with glass. Set up a light source around the transparent board to facilitate lighting, and install two BRIO webcams (Logitech, USA) on both sides of the transparent board (keep a distance from the board) to ensure the field of vision of the webcam Cover the entire board area. On the other hand, the drug database built in Example 1 is first stored in the real-time embedded computing device JETSON TM TX2 (NVIDIA, USA). JETSON TM TX2, called the "developer kit", contains memory, CPU, GPU, USB port, mesh antenna and other computing components, so that image processing steps and machine learning steps can be performed on the same device Executed within. In operation, two webcams can be connected to JETSON TM TX2 via a USB cable. According to this, the front and back images of the selected drug can be simultaneously transmitted to the processor in real time. The two original images of the selected drug blister package are processed into an RTI, and then the RTI accepts the learning model Tiny YOLO programmed in JETSON TM TX2 for subsequent procedures. The visual recognition speed of Tiny YOLO model can reach about 200 frames per second (FPS). The total process (ie, from capturing images to visual recognition) takes about 6.23 frames per second. The recognition result can be displayed on an external display device in real time, such as a computer screen or a mobile phone interface. Therefore, the external user can almost get the identification result of the medicine after putting the medicine on the glass plate body at the same time.

再者,為了評估本發明系統是否可有效地降低配藥過程人為疏失之機率,再次進行另一比較。舉例來說,一抗焦慮藥物:樂耐平(Lorazepam),其外觀與其他藥物的相似度頗高,因此在配藥過程中是最容易誤認的藥物。首先,將樂耐平的RTI輸入本發明系統,以與該資料庫中的所有藥物進行比較。經計算後,學習模型提出經該學習模型分析後基於外觀相似度可能誤認的數種候選藥物。候選表單可協助臨床人員複核所選藥物是否正確。因此,藉由本揭示內容的藥物管理系統,可改善配藥的準確度,也可以將人為疏失減至最小以確保病患安全。Furthermore, in order to evaluate whether the system of the present invention can effectively reduce the probability of human error in the dispensing process, another comparison is made again. For example, an anti-anxiety drug: Lorazepam, whose appearance is quite similar to other drugs, so it is the most misidentified drug during the dispensing process. First, the RTI of lenapine is entered into the system of the present invention to compare with all drugs in the database. After calculation, the learning model proposes several drug candidates that may be misidentified based on the similarity of appearance after the analysis of the learning model. The candidate form can assist clinical staff in reviewing whether the selected drug is correct. Therefore, with the drug management system of the present disclosure, the accuracy of dispensing drugs can be improved, and human error can be minimized to ensure patient safety.

總言之,本發明用於藥物管理之方法和系統可藉由在一個半開放式機構下執行影像處理步驟以將影像合併成一張,以及以實時的方式執行深度學習模型,藉以達成前述目的。本揭示內容的優勢不僅在於無論物體(即:藥物)的方位為何及初始攝像的角度為何,皆可快速地將原始影像經糾正規整程序製成一句有固定規格尺寸的整併影像,不僅利於機器學習的效率,還可經由藥物外觀增加藥物分類的準確性。In short, the method and system for drug management of the present invention can achieve the aforementioned objectives by performing image processing steps in a semi-open mechanism to merge images into one, and executing the deep learning model in real-time. The advantage of this disclosure is not only that regardless of the orientation of the object (i.e., the drug) and the angle of the initial camera, the original image can be quickly corrected and organized into a consolidated image with a fixed size, which is not only beneficial to the machine The efficiency of learning can also increase the accuracy of drug classification through the appearance of the drug.

應當理解的是,前述對實施方式的描述僅是以實施例的方式給出,且本領域所屬技術領域中具有通常知識者可進行各種修改。以上說明書、實施例及實驗結果提供本發明之例示性實施方式之結構與用途的完整描述。雖然上文實施方式中揭露了本發明的各種具體實施例,然其並非用以限定本發明,本發明所屬技術領域中具有通常知識者,在不悖離本發明之原理與精神的情形下,當可對其進行各種更動與修飾,因此本發明之保護範圍當以附隨申請專利範圍所界定者為準。It should be understood that the foregoing description of the embodiments is only given in the form of examples, and various modifications can be made by those with ordinary knowledge in the technical field of the art. The above specification, examples and experimental results provide a complete description of the structure and use of the exemplary embodiments of the present invention. Although various specific embodiments of the present invention are disclosed in the above embodiments, they are not intended to limit the present invention. Those with ordinary knowledge in the technical field to which the present invention belongs, without departing from the principle and spirit of the present invention, Various changes and modifications can be made to it, so the protection scope of the present invention shall be subject to the scope of the accompanying patent application.

100                    方法 102–110            步驟 200                    藥物管理系統 210                    影像擷取裝置 211                   透明板體 213                    第一影像擷取單元 215                    第二影像擷取單元 220                    影像處理器 230                    藥物資料庫 240                    機器學習處理器 100 Method 102–110 Steps 200 Drug management system 210 Image capture device 211 Transparent board 213 The first image capture unit 215 Second image capture unit 220 Image processor 230 Drug database 240 Machine learning processor

為讓本發明的上述與其他目的、特徵、優點與實施例能更明顯易懂,所附圖式之說明如下。In order to make the above and other objects, features, advantages and embodiments of the present invention more comprehensible, the description of the accompanying drawings is as follows.

第1圖是根據本揭示內容實施方式的方法100繪示的流程圖。FIG. 1 is a flowchart of a method 100 according to an embodiment of the present disclosure.

第2圖是繪示本揭示內容一實施方式的藥物管理系統200。FIG. 2 shows a medication management system 200 according to an embodiment of the present disclosure.

第3圖繪示本揭示內容之一實例,以例示如何透過單應性矩陣求糾正影像。Figure 3 shows an example of the present disclosure to illustrate how to correct the image through the homography matrix.

第4圖繪示本揭示內容之一實例,以例示如何透過質心演算法定義包裝的角點。Figure 4 shows an example of the present disclosure to illustrate how to define the corner points of the package through the centroid algorithm.

根據慣常的作業方式,圖中各種元件與特徵並未依比例繪製,其繪製方式是為了以最佳的方式呈現本發明相關的具體特徵與元件。此外,在不同的圖式間,以相同或相似的元件符號來指稱相似的元件/部件。According to the usual operation method, the various elements and features in the figure are not drawn to scale, and the drawing method is to present the specific features and elements related to the present invention in the best way. In addition, between different drawings, the same or similar element symbols are used to refer to similar elements/components.

100                    方法 102–110            步驟 100 Method 102–110 Steps

Claims (10)

一種用以建立一藥物泡型包裝影像之藥物資料庫的電腦實施方法,包含:(a)分別取得該藥物泡型包裝之一第一影像及一第二影像,其中該第一影像及該第二影像分別包含該藥物泡型包裝之一第一面及一第二面;(b)分別對該第一影像及該第二影像進行影像糾正(image rectification),以產生一糾正後第一影像及一糾正後第二影像;(c)規整(juxtapose)該糾正後第一影像及該糾正後第二影像,以產生一合併影像;(d)以一機器學習演算法來訓練該合併影像,以產生一參考影像;以及(e)借助於該參考影像以建立該藥物資料庫,其中步驟(c)包含:(c-1)提取該糾正後第一影像及該糾正後第二影像中,該藥物泡型包裝第一面及第二面之輪廓,以分別產生一第一輪廓影像及一第二輪廓影像;(c-2)識別該第一輪廓影像及該第二輪廓影像中各輪廓的角點,以確定該角點之座標;(c-3)根據步驟(c-2)之該座標,旋轉步驟(c-1)之該第一輪廓影像及該第二輪廓影像,以分別形成一第一處理影像及一第二處理影像;以及(c-4)規整步驟(c-3)之該第一處理影像及第二處理影像,以產生該合併影像。 A computer-implemented method for establishing a drug database of a drug blister package image includes: (a) obtaining a first image and a second image of the drug blister package, respectively, wherein the first image and the first image The two images respectively include a first side and a second side of the drug blister package; (b) performing image rectification on the first image and the second image respectively to generate a corrected first image And a corrected second image; (c) juxtapose the corrected first image and the corrected second image to generate a merged image; (d) train the merged image with a machine learning algorithm, To generate a reference image; and (e) use the reference image to establish the drug database, wherein step (c) includes: (c-1) extracting the corrected first image and the corrected second image, The contours of the first side and the second side of the drug blister package to generate a first contour image and a second contour image respectively; (c-2) Identify each contour in the first contour image and the second contour image (C-3) According to the coordinates of step (c-2), rotate the first contour image and the second contour image of step (c-1) to determine the coordinates of the corner point; Forming a first processed image and a second processed image; and (c-4) the first processed image and the second processed image of the normalizing step (c-3) to generate the combined image. 如請求項1所述之電腦實施方法,其中在步驟(b)中,以下述步驟來對該第一影像進行影像糾正:(b-1)提供一參考矩形;(b-2)選定該第一影像中四個角點,其中該四個角點構成一四邊形;(b-3)基於步驟(b-1)提供之該參考矩形與步驟(b-2)選定之該四邊形的對應關係,計算該參考矩形與該四邊形之對應關係的一第一單應性矩陣(homography matrix);以及(b-4)根據該第一單應性矩陣對該第一影像進行透視校正(perspective correction),以獲得該糾正後第一影像。 The computer-implemented method according to claim 1, wherein in step (b), image correction is performed on the first image by the following steps: (b-1) providing a reference rectangle; (b-2) selecting the first image Four corner points in an image, where the four corner points constitute a quadrilateral; (b-3) based on the correspondence between the reference rectangle provided in step (b-1) and the quadrilateral selected in step (b-2), Calculating a first homography matrix of the corresponding relationship between the reference rectangle and the quadrilateral; and (b-4) performing perspective correction on the first image according to the first homography matrix, To obtain the corrected first image. 如請求項2所述之電腦實施方法,其中步驟(b-2)之該四邊形係對應該藥物泡型包裝第一面之一輪廓。 The computer-implemented method according to claim 2, wherein the quadrilateral in step (b-2) corresponds to an outline of the first side of the drug blister package. 如請求項1或2所述之電腦實施方法,其中在步驟(b)中,以下述步驟來對該第二影像進行影像糾正:(b-i)基於該糾正後第一影像與該第二影像之間的對應關係,計算兩者間的一第二單應性矩陣;以及(b-ii)根據該第二單應性矩陣對該第二影像進行透視校正,以獲得該糾正後第二影像。 The computer-implemented method according to claim 1 or 2, wherein in step (b), image correction is performed on the second image by the following steps: (bi) based on the difference between the corrected first image and the second image Calculating a second homography matrix between the two; and (b-ii) performing perspective correction on the second image according to the second homography matrix to obtain the corrected second image. 如請求項1所述之電腦實施方法,其中以一直線轉換演算法或一質心演算法來執行步驟(c-2)。 The computer-implemented method according to claim 1, wherein step (c-2) is performed by a linear conversion algorithm or a centroid algorithm. 如請求項1所述之電腦實施方法,其中該第一面與該第二面分別是該藥物泡型包裝的正面及反面。 The computer-implemented method according to claim 1, wherein the first side and the second side are the front side and the back side of the drug blister package, respectively. 一種藥物管理系統,包含:一影像擷取裝置,用以擷取一藥物的一泡型包裝之影像,包含:一透明板體,用以使該藥物放置其上;一第一影像擷取單元,設置於該透明板體之一側,用以以一第一角度擷取該藥物的一第一影像,其中該第一影像包含該藥物泡型包裝之一第一面;以及一第二影像擷取單元,設置於該透明板體之另一側,用以以一第二角度擷取該藥物的一第二影像,其中該第二影像包含該藥物泡型包裝之一第二面,一影像處理器,經指令編程執行一第一電腦實施方法,係用於產生一候選影像,其中該第一電腦實施方法包含:(a)分別對該第一影像及該第二影像進行影像糾正,以分別產生一糾正後第一影像及一糾正後第二影像;以及(b)規整該糾正後第一影像及該糾正後第二影像,以產生該候選影像,一如請求項1所述之電腦實施方法建立的藥物資料庫,用以提供一參考影像;以及 一機器學習處理器,經指令編程執行一第二電腦實施方法,係用於比對該候選影像與該如請求項1所述之電腦實施方法建立的該藥物資料庫之該參考影像。 A medicine management system, comprising: an image capturing device for capturing an image of a blister package of a medicine, comprising: a transparent plate for placing the medicine on it; and a first image capturing unit , Arranged on one side of the transparent plate body to capture a first image of the medicine at a first angle, wherein the first image includes a first surface of the medicine blister package; and a second image The capturing unit is arranged on the other side of the transparent plate to capture a second image of the drug at a second angle, wherein the second image includes a second side of the drug blister package, a The image processor is programmed to execute a first computer-implemented method through instructions to generate a candidate image, wherein the first computer-implemented method includes: (a) performing image correction on the first image and the second image respectively, To respectively generate a corrected first image and a corrected second image; and (b) normalize the corrected first image and the corrected second image to generate the candidate image, as described in claim 1 The drug database established by the computer-implemented method is used to provide a reference image; and A machine learning processor, programmed with instructions to execute a second computer-implemented method, is used to compare the candidate image with the reference image of the drug database created by the computer-implemented method according to claim 1. 如請求項7所述之系統,其中步驟(b)包含:(b-1)提取該糾正後第一影像及該糾正後第二影像中,該藥物泡型包裝之該第一面及該第二面之輪廓,以分別產生一第一輪廓影像及一第二輪廓影像;(b-2)識別該第一輪廓影像及該第二輪廓影像中各輪廓的角點,以確定該角點之座標;(b-3)根據步驟(b-2)的該座標,旋轉步驟(b-1)之該第一輪廓影像及該第二輪廓影像,以分別形成一第一處理影像及一第二處理影像;以及(b-4)規整步驟(b-3)之該第一處理影像及第二處理影像,以產生該候選影像。 The system according to claim 7, wherein step (b) comprises: (b-1) extracting the first side and the second side of the drug blister package from the corrected first image and the corrected second image The contours of the two sides to respectively generate a first contour image and a second contour image; (b-2) Identify the corner points of each contour in the first contour image and the second contour image to determine the corner point Coordinates; (b-3) According to the coordinates of step (b-2), rotate the first contour image and the second contour image of step (b-1) to form a first processed image and a second Processing the image; and (b-4) the first processed image and the second processed image of the normalizing step (b-3) to generate the candidate image. 如請求項7所述之系統,其中該第一面與該第二面分別是該藥物泡型包裝的正面及反面。 The system according to claim 7, wherein the first side and the second side are the front side and the back side of the drug blister package, respectively. 如請求項7所述之系統,其中該第一角度以及該第二角度分別相對於該透明板體之水平面為40至90度。 The system according to claim 7, wherein the first angle and the second angle are respectively 40 to 90 degrees with respect to the horizontal plane of the transparent plate.
TW108143018A 2019-11-26 2019-11-26 Method and system for building medication library and managing medication via the image of its blister package TWI731484B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW108143018A TWI731484B (en) 2019-11-26 2019-11-26 Method and system for building medication library and managing medication via the image of its blister package

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW108143018A TWI731484B (en) 2019-11-26 2019-11-26 Method and system for building medication library and managing medication via the image of its blister package

Publications (2)

Publication Number Publication Date
TW202121283A TW202121283A (en) 2021-06-01
TWI731484B true TWI731484B (en) 2021-06-21

Family

ID=77516747

Family Applications (1)

Application Number Title Priority Date Filing Date
TW108143018A TWI731484B (en) 2019-11-26 2019-11-26 Method and system for building medication library and managing medication via the image of its blister package

Country Status (1)

Country Link
TW (1) TWI731484B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473541A (en) * 2013-08-21 2013-12-25 方正国际软件有限公司 Certificate perspective correction method and system
US9122921B2 (en) * 2013-06-12 2015-09-01 Kodak Alaris Inc. Method for detecting a document boundary
CN106991649A (en) * 2016-01-20 2017-07-28 富士通株式会社 The method and apparatus that the file and picture captured to camera device is corrected
CN107368829A (en) * 2016-05-11 2017-11-21 富士通株式会社 The method and apparatus for determining the rectangular target areas in input picture
CN108830186A (en) * 2018-05-28 2018-11-16 腾讯科技(深圳)有限公司 Method for extracting content, device, equipment and the storage medium of text image
CN110278343A (en) * 2016-02-09 2019-09-24 富士施乐株式会社 Image processing apparatus and image processing method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9122921B2 (en) * 2013-06-12 2015-09-01 Kodak Alaris Inc. Method for detecting a document boundary
CN103473541A (en) * 2013-08-21 2013-12-25 方正国际软件有限公司 Certificate perspective correction method and system
CN106991649A (en) * 2016-01-20 2017-07-28 富士通株式会社 The method and apparatus that the file and picture captured to camera device is corrected
CN110278343A (en) * 2016-02-09 2019-09-24 富士施乐株式会社 Image processing apparatus and image processing method
CN107368829A (en) * 2016-05-11 2017-11-21 富士通株式会社 The method and apparatus for determining the rectangular target areas in input picture
CN108830186A (en) * 2018-05-28 2018-11-16 腾讯科技(深圳)有限公司 Method for extracting content, device, equipment and the storage medium of text image

Also Published As

Publication number Publication date
TW202121283A (en) 2021-06-01

Similar Documents

Publication Publication Date Title
US10467477B2 (en) Automated pharmaceutical pill identification
WO2019196308A1 (en) Device and method for generating face recognition model, and computer-readable storage medium
WO2020000908A1 (en) Method and device for face liveness detection
TWI754806B (en) System and method for locating iris using deep learning
BR112020018915A2 (en) METHOD FOR IDENTIFYING AN OBJECT IN AN IMAGE AND MOBILE DEVICE FOR IMPLEMENTING THE METHOD
CN103902958A (en) Method for face recognition
WO2021012494A1 (en) Deep learning-based face recognition method and apparatus, and computer-readable storage medium
CN102930278A (en) Human eye sight estimation method and device
CN109615010B (en) Traditional Chinese medicine material identification method and system based on double-scale convolutional neural network
US10699162B2 (en) Method and system for sorting and identifying medication via its label and/or package
JP6820886B2 (en) Methods and systems for classifying and identifying drugs by drug label and / or packaging
CN111382622A (en) Medicine identification system based on deep learning and implementation method thereof
CN111860055A (en) Face silence living body detection method and device, readable storage medium and equipment
CN1776712A (en) Human face recognition method based on human face statistics
Wu et al. Appearance-based gaze block estimation via CNN classification
TWI731484B (en) Method and system for building medication library and managing medication via the image of its blister package
TWI692356B (en) Method of monitoring medication regimen complemented with portable apparatus
TWI695347B (en) Method and system for sorting and identifying medication via its label and/or package
CN116881886A (en) Identity recognition method, identity recognition device, computer equipment and storage medium
CN114360031B (en) Head pose estimation method, computer device, and storage medium
TWI756004B (en) Medicine cabinet system with image recognition training module
CN103995586B (en) Non- wearing based on virtual touch screen refers to gesture man-machine interaction method
Hnoohom et al. Blister Package Classification Using ResNet-101 for Identification of Medication
WO2020152599A1 (en) Method for verifying the identity of a user by identifying an object within an image that has a biometric characteristic of the user and mobile device for executing the method
CN117152397B (en) Three-dimensional face imaging method and system based on thermal imaging projection