INTRODUCTION
PROBLEM STATEMENT
Health is crucial to our well-being, and blood testing has emerged as a key area of medical diagnostics, encompassing biochemical testing, hematology, blood clotting, and blood grouping These tests are essential for identifying early signs of blood abnormalities, allowing for timely treatment The history of blood transfusion highlights the importance of understanding blood compatibility; in 1901, Austrian doctor Karl Landsteiner made a groundbreaking discovery by identifying the first three human blood types: A, B, and O.
O One year later, the 4th blood type (AB) recorded by A Decastrello and A Sturli. More than 40 years later, a factor considered to be the leading cause of blood transfusion reactions (Rh factor) was discovered by Karl Landsteiner, Alex Wiener, Philip Levine and RE Stetson Along with the ABO blood type system, the Rh factor is seen as a breakthrough in blood banking [1]
In the last century, blood grouping tests primarily relied on two methods: testing on enamel slabs and in vitro, which, while simple and cost-effective, were prone to technical errors and administrative confusion due to user skill levels To address these issues, Dr Yves Lapierre introduced Gel technology in 1988, significantly improving the accuracy of blood grouping Today, the Gel Card is widely recognized as the most effective method for blood grouping in hospitals, clinics, and laboratories.
The Gel Card Reader, a device essential for blood grouping, is currently utilized in hospitals across Vietnam and worldwide, yet its price exceeds 5000 USD To address this issue, our team has embarked on a graduation thesis project aimed at designing a cost-effective Gel Card Reader that maintains the same blood group determination capabilities This innovative device will utilize a camera to capture images of the Gel Card containing treated blood, which will then be processed by a central unit using advanced image processing algorithms to accurately determine blood groups This initiative promises to make significant contributions to the field of medical testing by providing a more affordable solution.
THESIS CONTENTS
This project is conducted under the guidance of Assoc Prof Dr Nguyen Thanh Hai, ensuring that the research is original and authentic We affirm that the results presented are genuine and have not been duplicated from any other sources.
Nguyễn Minh ĐứcTrương Hoàng Gia Bảo
We would like to express our heartfelt gratitude to Assoc Prof Dr Nguyen Thanh Hai for his invaluable support and dedication in guiding us through our graduation project His expertise not only enriched our knowledge but also instilled in us the importance of a serious approach to scientific research, which is essential for our future careers.
We would like to express our heartfelt gratitude to the teachers in the Department of Industrial Electronics - Biomedical Engineering for creating an optimal environment for our project completion Our appreciation also extends to all lecturers who imparted foundational knowledge in previous semesters, enabling us to successfully finalize our work Special thanks to Ms Huong, Head of the Laboratory Department at Thu Duc General Hospital, for providing Gel Card samples essential for our project We are grateful to Nghia Tin Medical Equipment Co., Ltd for their support with equipment and ideas, and to Mr Ngo Thien Ha, Deputy Director of Duong Phu Technology Co., Ltd, for offering facilities and equipment crucial to our implementation Lastly, we thank our parents for their unwavering dedication and hard work in supporting our education, as the longer we work, the more we appreciate their sacrifices.
Finally, we would like to express our sincere thanks to the people who have contributed and helped the group to implement this project successfully.
Ho Chi Minh City, January 20,
Nguyễn Minh ĐứcTrương Hoàng Gia Bảo
2.2 GEL CARD METHOD AND TYPE OF GEL CARDS 5
3.2.1 Block Diagram Of An Capturing Device 13
3.2.6 Case designs for the Gel Card Reader 25
3.4.1 Functional summary of Gel Card Reader 28
3.4.3 A flowchart of agglutination level and blood type 29
Chapter 4 CONNECTION OF SYSYTEM PARTS 37
4.2.1 Assembly of the Power Supply 37
4.2.2 Execution of The Power Supply 37
4.2.3 Inspection of The Power Supply 40
4.3 EXECUTION THE CASE OF GEL CARD READER 41
5.2.5 Result of Gel Card Reader 51
Chapter 6 FUTURE WORKS AND CONCLUSION 57
Figure 2 1 The ABO blood grouping system (Source: Wikipedia) 4
Figure 2 2 Gel Card and parts inside the Gel Card tube 5
Figure 2 4 Sample of Forward grouping Gel Card 7
Figure 2 5 Dilation in image processing (Source: www.cs.auckland.nz) 8
Figure 2 6 Raspberry Pi 4B (Source: www.deskmodder.de) 11
Figure 3 1 Block diagram of the system 13
Figure 3 3 Block diagram of the switching power supply 16
Figure 3 4 Schematic of noise filter and primary voltage rectifier circuit 20
Figure 3 5 Schematic of pulse generator circuit 22
Figure 3 6 Schematic of secondary voltage rectifier circuit 23
Figure 3 7 Schematic of secondary voltage feedback circuit 24
Figure 3 8 Schematic of switching power supply circuit 25
Figure 3 9 Frontside (a) and backside (b) of the base holder 26
Figure 3 10 The frontside (a) and backside (b) of the Gel Card Reader case 27
Figure 3 11 The connection of the entire project Interpret connection diagrams 27
Figure 3 12 Flowchart of Gel Card Reader system 29
Figure 3 13 A flowchart of agglutination level and blood type 30
Figure 3 14 Image area is cropped in Gel Card (red border) 31
Figure 3 15 The result after image cutting in Gel Card Reader 31
Figure 3 16 RGB to HSV diagram 32
Figure 3 17 Results after converted image from RGB to HSV 32
Figure 3 18 The selectable color threshold for filtering 32
Figure 3 19 Image after processed with threshold 33
Figure 3 20 Determine binary image area and draw contour 34
Figure 3 21 The value belong x and y axis of center point in binary image 34
Figure 3 22 Flowchart of blood type determination in Gel Card Reader 35
Figure 4 1 The top side (a) and bottom side (b) of PCB 39
Figure 4 2 The 5 Volt switching power supply 39
Figure 4 5 Graphic User Interface of Gel Card Reader
Figure 4 6 PyCharm IDE for python programming
Figure 4 7 Gel Card GUI is built on QT Designer
Figure 5 1 Input, output jacks of the switching power supply .
Figure 5 2 Measure output voltage when the load is connected .
Figure 5 3 GUI of a Gel Card Reader Figure 5 4 Gel Card Reader system
Figure 5 5 Sample is put into Gel Card Reader
Figure 5 6 The Result interpretation Figure 5 7 Wrong Gel Card recognition
Figure 5 8.The result interpretation (Sample 1: O- ; Sample 2: B+)
Figure 5 9.The result interpretation (Sample 1: A+ ; Sample 2: B-)
Figure 5 10 DG Reader of GRIFOLS
Figure 5 11 Gel Card Reader and GRIFOLS’s DG Reader Comparison xi
This article includes a comprehensive comparison of all Raspberry Pi generations, highlighting their specifications and features It also details the power consumption of various circuits, including input filters, rectifiers, and pulse generating circuits Additionally, the article outlines the electronic components used in secondary voltage rectifier and feedback circuits, as well as those found in the switching power supply board Furthermore, it presents data on the voltage outputs and inputs during power supply testing, alongside the accuracy and efficiency metrics of the Gel Card Reader.
The "Design of a Gel Card Reader for Blood Grouping Tests" focuses on developing a system that accurately reads Gel Cards used in blood grouping, identifies defective cards, and manages patient data Utilizing the unique agglutination of gel columns, the project achieves high accuracy in determining various blood types The process begins with capturing an image of the Gel Card via a camera, followed by data transfer to a Raspberry Pi 4B for image processing and result computation Finally, the results are displayed on a user-friendly interface, with the added capability of saving outcomes to efficiently manage patient information.
Health is crucial to our well-being, and blood testing has emerged as a key component in medical diagnostics, encompassing biochemical testing, hematology, blood clotting, and blood grouping These tests are essential for identifying early signs of blood abnormalities, allowing for timely treatment The quest for safe blood transfusion dates back centuries, driven by the need to understand why blood from different individuals could not be transfused safely A significant breakthrough occurred in 1901 when Austrian doctor Karl Landsteiner discovered the first three human blood types: A, B, and O, laying the groundwork for modern transfusion practices.
O One year later, the 4th blood type (AB) recorded by A Decastrello and A Sturli. More than 40 years later, a factor considered to be the leading cause of blood transfusion reactions (Rh factor) was discovered by Karl Landsteiner, Alex Wiener, Philip Levine and RE Stetson Along with the ABO blood type system, the Rh factor is seen as a breakthrough in blood banking [1]
In the last century, blood grouping tests primarily relied on two methods: testing on enamel slabs and in vitro, which, while simple and cost-effective, were prone to technical errors and administrative confusion based on user expertise In 1988, Dr Yves Lapierre introduced Gel technology to address these issues, leading to the development of the Gel Card, which has since become the most effective and widely used method for blood grouping in hospitals, clinics, and laboratories.
The Gel Card Reader, a device used for determining blood groups, is currently utilized in hospitals across Vietnam and worldwide, but its price exceeds 5,000 USD To address this issue, a project has been initiated to research and manufacture a more affordable Gel Card Reader that maintains similar blood grouping capabilities, which could greatly enhance medical testing accessibility This graduation thesis focuses on designing a Gel Card Reader that employs a camera to capture images of the Gel Card containing treated blood The captured images are then processed by a central processing unit using specialized algorithms to accurately determine the blood group results.
This project focuses on developing a blood group classification system utilizing a Gel Card The system is built around a Raspberry Pi 4B, integrated with a camera and a display, complemented by advanced image processing algorithms.
● CONTENT 1: Research on blood group system, Gel Card method.
● CONTENT 2: Research the functions of Gel Card Reader.
● CONTENT 3: Design flowchart, write the code for image processing.
● CONTENT 4: Designing a power supply for Gel Card Reader.
● CONTENT 5: Designing a case for Gel Card Reader.
● CONTENT 6: Design a graphical user interface (GUI) for the system.
● CONTENT 7: Execute the system, evaluate the results, compare with similar equipment, re-evaluate the advantages and disadvantages.
LIMITATIONS
● No results will be saved in the event of a power failure.
● Card Reader only reads with popular Cel Cards as Forward, Forward and Reverse, CrossMatch, Coombs.
● The instrument does not recognize the type of Gel Cards through the barc 1.5 BRIEF SUMMARY OF THESIS
This chapter shows the Gel Card method's importance, point out the topic's limitations, goals, and make lists.
This chapter describes the theoretical basis of “Design of a Gel Card Reader for blood grouping tests” and the model's working principle.
This chapter presents to choose the components and learn how to connect them, and suggest the system's design method.
Chapter 4: Connection of system parts
This chapter shows how the system is executed and applied to the image processing method.
This chapter discusses the results achieved after completing the system, commenting on the results achieved.
Chapter 6: Conclusion and future works
This chapter shows the conclusion about the things that we complete, not complete and some drawbacks Present the plan of the topic in the future.
BRIEF SUMMARY OF THESIS
In this chapter, an overview of theories related to the Gel Card Reader implementation is presented.
Human blood consists of four primary components: red blood cells, white blood cells, plasma, and platelets Among these, red blood cells play a crucial role in determining blood types The ABO blood type system is the principal method used to classify blood types into A, B, AB, and O.
Blood types are categorized by the presence or absence of specific antigens on red blood cells, which trigger an immune response Individuals with A antigens are classified as blood type A, while those with B antigens are classified as blood type B If both A and B antigens are present, the blood type is AB Conversely, the absence of both A and B antigens designates the individual as having Blood Type O.
Figure 2 1 The ABO blood grouping system (Source: Wikipedia)
The basic grouping system consists of eight classifications based on the Rhesus factor, commonly referred to as the 'Rh' factor This term originates from the Rhesus monkey, where the Rh antigen was initially discovered The presence of the Rhesus D factor is particularly significant in this classification.
LITERATURE REVIEW
TYPES OF HUMAN BLOOD
Human blood consists of four primary components: red blood cells, white blood cells, plasma, and platelets Among these, red blood cells play a crucial role in determining blood types The ABO blood type system is the primary method used to classify blood into four types: A, B, AB, and O.
Blood types are determined by the presence or absence of specific antigens on red blood cells A person with A antigens has blood type A, while those with B antigens are classified as blood type B If both A and B antigens are present, the blood type is AB Conversely, individuals lacking both A and B antigens are identified as having blood type O.
Figure 2 1 The ABO blood grouping system (Source: Wikipedia)
The basic blood grouping system consists of eight groups based on the Rhesus factor, commonly known as the 'Rh' factor, named after the Rhesus monkey where the antigen was first identified Individuals with the Rhesus D factor in their blood are classified as Rhesus positive, while those without it are deemed Rhesus negative Consequently, blood types can be categorized as either AB or negative O when considering both the ABO and Rhesus classification systems.
The Rhesus factor is crucial in pregnancy, as a mismatch can jeopardize the infant's life If a baby inherits Rhesus positive blood from the father while the mother has Rhesus negative blood, the mother's immune system may produce antibodies that attack the child's blood.
GEL CARD METHOD AND TYPE OF GEL CARDS
Gel Technology utilizes a specialized plastic card known as the Gel Card, which contains six or eight microtubes pre-filled with specific gel and reagents (Anti A, Anti B, Anti D, AHG) tailored to the card's parameters These gel plates function as a sieve, allowing only single normal red blood cells to pass through, while agglomerated erythrocytes are captured within the gel column The sensitivity of the system is influenced by the size of the gel and gel particles.
Figure 2 2 Gel Card and parts inside the Gel Card tube
A red blood cell suspension was created using Low Ion Strength Solution (LISS), combined with serum or plasma, and placed in the reaction chamber of microtubules After incubating the gel tag for antigen-antigen reactions, the Gel Card was centrifuged for 10 minutes at 85g Under these conditions, only a single normal red blood cell can pass through the gel and settle at the bottom, forming a knot The reacted or agglomerated cells are retained in the gel column, with their position indicating the size of the agglutination, thereby aiding in the classification of the reaction.
4 + RBCs are agglutinated at the top of the gel column.
3 + Most of the agglutination erythrocytes remain in the upper half of the gel column.
2 + Red cell agglutination is observed throughout the length of the column A few groups of red blood cells may also be displayed at the bottom of the gel column.
1 + Most RBCs are in the lower half of the column Some can also be shown at the bottom of the gel column.
All red blood cells pass through and form a compact knot at the bottom of the gel. All 4+ 3+ 2+ 1+ case are positive, 0 or - considered negative.
2.2.2 Type of Gel Cards a) Forward grouping Gel Card
The Forward grouping Gel Card features eight microtubes, utilizing four specific tubes for each test: Tube A with antibodies A, Tube B with antibodies B, Tube D with antibodies D, and Tube Ctrl, which serves as a neutral control environment An example of the Forward card is illustrated in Figure 2.4 below.
For a patient with blood type A, characterized by A antigens and B antibodies, the process begins by diluting the erythrocyte solution with LISS solution The upper suspension is then injected into three tubes of ABD and centrifuged at 880 rpm for 10 minutes The results will be displayed on the Gel Card, indicating the blood type and compatibility.
Column A contains antibodies A, so the patient's A antigen will be retained by antibody A and not pulled down by centrifugal force The result will be positive.
Column B contains antibody B, so the patient's A antigen will not be retained by antibody A The results will be negative.
Column D is used to determine the blood group system of patients with Rh + or Rh- systems, if there is a positive agglutination present, Rh + patients, if negative, Rh- patients
To assess the quality of the Gel Card, refer to the Ctrl column; a negative value indicates that the Gel Card is still valid, while a positive value signifies that it is no longer available.
Figure 2 4 Sample of Forward grouping Gel Card b) Card Reader
After combining all the ingredients, the Gel Card is subjected to centrifugal force of 85g, and if it includes an AHG tube, it is incubated at 37 degrees Celsius for 15 minutes The agglutination results are then visible on the card, and to facilitate quick and accurate reading, a Gel Card Reader employs image processing technology to assess the level of condensation in the gel column.
IMAGE PROCESSING ALGORITHM
The expansion operation, denoted as A⊕B = ⋃Bx where x⊂A, is a mathematical process used to increase the size of an object within an image In this context, A represents the object, while B refers to the image structuring element, which is a predefined shape, such as a square or a cross, that interacts with the image This operation effectively enhances the original object's dimensions by assessing its interaction with the structuring element.
Figure 2 5 Dilation in image processing (Source: www.cs.auckland.nz)
The image expansion algorithm plays a crucial role in various practical applications, including product classification and license plate detection This technique was notably utilized in the graduation project by Phan Thanh Phong and Nguyen Hien Minh, titled "APPLICATION OF IMAGE PROCESSING."
In the product classification system, the use of image expansion enhances object clarity, thereby improving classification accuracy This approach is exemplified in the graduation project by Vo Danh Quan and Nguyen Minh Hao, which focuses on counting the number of pills.
CÓ TRONG VỈ THUỐC" [4] also use expansion math to clarify the image of the pill so that the microcontroller can handle it.
Canny Edge Detection is an algorithm used to extract edges from images.
DEPARTMENT OF ELECTRONIC – BIOMEDICAL ENGINEERING 8
The algorithm has four stages:
First - Performs noise reduction with a Gaussian Blur.
Second - Gets the gradient direction and magnitude with a Sobel kernel.
Third - Applies non-maximum suppression, which removes unwanted pixels that are not part of a contour.
Fourth — Applies the Hysteresis Thresholding that uses min and max values to filter the contours by the intensity gradient [5]
In practical applications, edge detection is used in object detection and recognition In Nguyen Thanh Huy's master's thesis, University of Da Nang, the topic
“ỨNG DỤNG PHƯƠNG PHÁP PHÁT HIỆN BIÊN TRONG NHẬN DẠNG CÁC ĐỐI TƯỢNG HÌNH HỌC [6] ” Uses an edge detection method to detect objects.
IMAGE CAPTURING DEVICES
The image capturing device plays a crucial role in image processing, particularly when utilizing a high-resolution camera such as the HOCO DI01 webcam, which offers a resolution of 1920x1080 and is effective for close-up shots We chose this webcam for its affordability, high resolution, and user-friendly design, connecting seamlessly to a microcontroller via USB Cameras are now widely used in various applications, including product counting, classification systems, face recognition, and license plate detection.
Microcontrollers play a crucial role in embedded programming, with popular options including PIC16F887, STM32, Arduino, Intel Galileo, and Raspberry Pi Each microcontroller has unique features tailored for specific applications Notably, Raspberry Pi stands out in image processing due to its superior configuration, making it ideal for tasks ranging from basic product color checking and license plate detection to advanced applications like facial recognition and machine learning.
The Raspberry Pi is a microcontroller that is widely used in real-world applications Specifically, the graduation project of Nguyen Phuc Bao, Nguyen Le
Gia Bach, HCMUTE with the topic "DESIGN OF AN IMAGE ACQUISITION
The article discusses a system designed for detecting occlusal dental issues, utilizing a Raspberry Pi 3B as a microcontroller This project was developed by Le Hoang Thanh and Ho Dinh Vuong from HCMUTE, focusing on innovative solutions for dental diagnostics.
CÔNG HỆ THỐNG BẢO MẬT ỨNG DỤNG XỬ LÝ ẢNH [8] " There is also use of the Raspberry Pi 3B as a microcontroller.
Launched in 2019, the Raspberry Pi 4B is a powerful embedded computer, offering three times the performance of its predecessor, the Pi 3B, with RAM options of 2GB, 4GB, and 8GB Its application in image processing has become increasingly common, making it a more efficient choice compared to other embedded kits like Arduino, Intel Galileo, and NVidia Jetson Nano The significant RAM upgrade in the Pi 4B supports the team's image processing algorithms, which utilize Python programming This capability makes the Raspberry Pi 4B the ideal microcontroller for creating a compact Gel Card Reader, providing the necessary power and functionality for effective image processing tasks.
Figure 2 6 Raspberry Pi 4B (Source: www.deskmodder.de)
Table 2 1 Raspberry Pi all generations comparison.
The switching power supply has dominated the market for over 30 years, surpassing the traditional transistor linear power supply due to its compact size, higher efficiency, reduced heat generation, superior tuning capabilities, wider input voltage range, and affordability These advantages have made switching power supplies the preferred choice for various applications, including household appliances, industrial equipment, and electronic medical devices In contrast, linear power supplies, which utilize a 220VAC low-voltage transformer and IC 7805 for voltage stabilization, achieve only about 40% efficiency, while switching power supplies exceed 70% efficiency For reliable and long-term operation, a stable 5V switching power supply was selected to power the central processing unit (Raspberry).
DESIGN AND CALCULATION
INTRODUCTION
In this chapter, the design calculations and selection of components for Gel Card Reader include power circuit, image capturing device, device cover, and how to connect the components together.
CALCULATION AND DESIGN
3.2.1 Block Diagram Of An Capturing Device
Figure 3 1 Block diagram of the system
The system's block diagram, depicted in Figure 3.1, illustrates the Power Supply, which provides 5VDC to the Central Processing Unit, the Light Environment, and the Cooling Fan The Light Environment features a small LED bar that illuminates the Gel Card, ensuring clear image capture for data transmission to the camera.
The Central Processing Unit (CPU) processes input image data using various image processing methods in conjunction with a Raspberry Pi During operation, a cooling fan effectively dissipates heat generated by both the power and processor blocks Peripheral devices, including a keyboard and mouse, facilitate system operation and allow for the input of patient data Ultimately, the blood group results are displayed on the screen for easy access.
In the topic, the system uses the Hoco D101 webcam because it is cheap (about $
15) but with good quality Video quality is bright and clear, with up to Full HD resolution, good refresh rate and virtually no stutter even in low-light environments.
Image capturing device has 4 pins, including: GND, 5V DC, DATA+, DATA-. The camera has a built-in ADC converter and offers 2 outputs: DATA + and DATA-
The Raspberry Pi 4B, launched in 2019, is the most powerful model to date, designed to receive and process images from a camera and display the results on a user interface It connects to a 5V 5A power supply via its USB Type-C port and features a micro HDMI output for a 14-inch LCD screen This enhanced configuration significantly improves processing speed, allowing for a higher number of samples to be measured within an hour.
To effectively utilize the Raspberry Pi 4B as a computer, it is essential to connect monitors and peripherals for user-friendly interaction In this setup, a 13-inch Samsung LCD screen with HD resolution is employed, as HD resolution optimally balances visual clarity without compromising the device's performance and processing speed.
3.2.5 Calculation of Power Supply a) Calculation of Power Requirement
Table 3 1 The consumption power of the circuit
The sum of consumption power is described in the formula (3.1):
P1 = consumption power of Raspberry mainboard.
P2 = consumption power of Webcam USB.
P3 = consumption power of DC Fan.
P4 = consumption power of Led bar.
DEPARTMENT OF ELECTRONIC – BIOMEDICAL ENGINEERING 15
This is a minimum of power that our project requires As a result, we decided to make a switching power supply 5V-5A (25W). b) Circuit Composition of Switching Power Supply
The block diagram of most switching power supplies is shown in Figure 3.3.
Figure 3 3 Block diagram of the switching power supply
The AC input voltage is first rectified and filtered into DC voltage, which is then controlled by a high-frequency PWM signal to drive the primary of a switching transformer This transformer generates a high-frequency voltage on its secondary side, delivering power to the load after rectification and filtering A feedback mechanism relays information to the control circuit, adjusting the PWM duty ratio to maintain a stable output For easier calculation and design, the switching power circuit is segmented into smaller component circuits for analysis.
• Total output power is calculated as the formula (3.2):
• Power supply input with an efficiency of 75% is calculated as the formula (3.3):
Po = power of output. n = efficiency of input power supply.
• DC voltage input after rectifier is calculated as the formula (3.4):
• Average input current is calculated as the formula (3.5):
• The peak current on the transistor is calculated as the formula (3.6):
• Primary inductance is calculated as the formula (3.7):
Lpri = (V1 * Dmax) / (Ipk * f) = (220 * 0.45) / (0.625 * 300000) = 528 (uH) (3.7) Where:
Dmax = maximum duty cycle when flyback circuit is in interrupt mode, choose
• Number of primary winding is calculated as the formula (3.8):
Lpri = primary inductance is calculated above, converted to nH.
• The waveform of the primary current is a serrated pulse, so the r.m.s.value is calculated as the formula (3.9):
The switching transistor utilizes a 0.7mm winding for its primary coil, featuring a cross-sectional area of S = 0.384 mm² With a current density of J = 5A/mm², each winding can handle a current of S * J = 0.384 * 5 = 1.9A Therefore, a total of 38 turns of 0.7mm winding are required for the primary coil.
• Number of secondary winding is calculated as the formula (3.10):
Ns = Npri * (Vo + Vd) * (1 - Dmax) / (V1 * Dmax)
Vd = voltage drop of the secondary rectifier diode
• The maximum peak current through Transistor Q2 is calculated as the formula (3.11):
Dmax = maximum duty cycle when flyback circuit is in interrupt mode.
V1 = AC input voltage f = switching frequency
• Transistor Q2 working mode saturation in pulse generating circuit is calculated as the formula (3.12):
Ic = (V2 - Vcesat)/ Zlpri Zlpri = 2π * f * Lpri = 995 (Ω)
V2 = DC rectified voltage β = BJT's current amplification coefficient
Vcesat = Vce saturation of transistor Q2
Vbe = threshold voltage Vbe of transistor Q2 (~ 0.7V)
Ib = bias current pin B of transistor Q2
Zlpri = secondary winding impedance when operating at frequency f = 300kHz. Lpri = primary inductance
•Resistor values in the voltage divider bridge for TL431 and PC817 in the feedback circuit is calculated as the formula (3.13):
Vref = Reference voltage of TL431.
Input filter and rectifier circuit.
The 220AC voltage is first protected by a fuse (F1) and a varistor (VR1) to guard against overcurrent and overvoltage It then passes through a high-frequency noise filter, composed of capacitor (CX1) and inductor (LF1), to eliminate noise before being rectified by a diode bridge into DC voltage To prevent sudden surges in charge current that could damage capacitor (C1), the DC voltage is routed through an NTC resistor The primary filter capacitor (C1) smooths the DC voltage and stores energy for the primary winding of the switching transformer (T1) Suitable components for the input filter and rectifier circuit are detailed in Table 3.2, while Figure 3.4 illustrates the schematic of the noise filter and voltage rectifier circuit.
Table 3 2 Electronic component of the input filter and rectifier circuit
Figure 3 4 Schematic of noise filter and primary voltage rectifier circuit Pulse generating circuit
The 310 DC voltage is routed through the priming resistor R5 and the switching transformer T1, powering the pulse generating circuit, which primarily consists of transistors Q1 and Q2 A critical aspect of the flyback power circuit is the polarity of its primary and secondary coils; to achieve a positive output voltage, the windings must have opposite polarities, while for a negative output, the polarities should align Table 3.3 lists the suitable components for the pulse generating circuit, illustrated in Figure 3.5.
Table 3 3 Electronic component of pulse generating circuit
Figure 3 5 Schematic of pulse generator circuit Secondary voltage rectifier circuits.
Transistor Q2 operates in an open/close mode to create a variable primary field in the switching transformer T1, resulting in induced voltage on the secondary side This induced voltage is then rectified to DC by the Schottky diode D3 and smoothed out by filter capacitors C7 and C8 to yield a stable 5V output power Table 3.4 provides a list of suitable components for the secondary voltage rectifier circuit, while Figure 3.6 illustrates the schematic of these rectifier circuits.
Table 3 4 Electronic component of secondary voltage rectifier circuit
Figure 3 6 Schematic of secondary voltage rectifier circuit
The secondary output voltage is linked to the sampling and fault voltage detection circuits, which primarily consist of an optocoupler (U1) and a voltage regulator (U2) to ensure stable operation of the pulse generator The components selected for the secondary voltage feedback circuits are detailed in Table 3.5, while Figure 3.7 illustrates the schematic of these feedback circuits.
Table 3 5 Electronic component of secondary voltage feedback circuits
Figure 3 7 Schematic of secondary voltage feedback circuit
The integrated switching power circuit operates with an input voltage of 220VAC and delivers a stable output of 5VDC It features essential protections against overcurrent and overvoltage, effectively filters noise, and ensures a steady output voltage Additionally, the design provides complete isolation of the secondary output voltage from the primary high voltage, enhancing safety A schematic representation of these switching power circuits is illustrated in Figure 3.8.
Figure 3 8 Schematic of switching power supply circuit 3.2.6 Case designs for the Gel Card Reader
To enhance the reliability of our device and stabilize its image capturing process, we utilized Solidworks for the design and employed 3D printing technology for fabrication The model consists of three distinct components.
- The device case. b) Base holder
The base holder is designed to securely fix the Gel Card tray holder, camera holder, and back cover of the device It features a dedicated space beneath the two holders to accommodate the power circuit, Raspberry Pi, LED lights, and connection cables Additionally, the back cover includes strategically placed holes for essential components such as the cooling fan, power switch, power cord, and Raspberry Pi connectors, including USB, LAN, HDMI, and Micro 3.5mm ports Figure 3.9 illustrates the shape of the base holder.
Figure 3 9 Frontside (a) and backside (b) of the base holder b) Device case
We designed a protective case for the device that ensures stable operation of the image capturing unit by creating an optimal lighting environment, resulting in consistent image quality Additionally, the case features a well-shaped opening on the top for easy insertion and removal of the Gel Card, as illustrated in Figure 3.10.
DEVICE CONNECTION
Design calculations are essential for any project, as they significantly influence the outcomes Careful selection of all equipment and components is crucial to achieve optimal results Consequently, a detailed description of the entire system's connections is necessary, as illustrated in Figure 3.11.
Figure 3 11 The connection of the entire project Interpret connection diagrams
The Raspberry Pi 4B operates using a 5V 5A power supply connected through a USB Type C port, which also powers USB LEDs and a heatsink fan A D1O1 Hoco Webcam connects to the Raspberry Pi via a USB 3.0 port, while a computer monitor is linked through the Micro HDMI port using a Micro HDMI to VGA converter cable Additionally, peripherals like the mouse and keyboard are connected through the USB ports.
FLOWCHART AND PROGRAM ALGORITHM
3.4.1 Functional summary of Gel Card Reader
The project "Designing a Gel Card Reader for blood grouping tests" requires a summary of the Gel Card Reader's functions to facilitate the creation of flowcharts and programming.
The Gel Card Reader is designed to read two types of Gel Cards: Forward and Forward Reverse To use the Forward Card, the user selects the Forward Grouping option on the interface, places the Card in the holder, and presses the View Result button The interface then displays the agglutination levels for each microtube, the results for both samples (for the Forward Card), and the final outcomes for both the Forward and Reverse Cards.
The defective Gel Card detection function is essential for assessing the quality of the Gel Card during testing via the Ctrl column When a faulty card is identified, the interface promptly displays the results in the result box.
After completing the test, users can efficiently enter and manage patient information, including full name, ID, date of birth, gender, and measurement results All collected data will be securely stored in the Program Database for future reference.
Figure 3 12 Flowchart of Gel Card Reader system
The Gel Card Reader system's control process, illustrated in Figure 3.12, begins with the booting of the system and the initiation of the program The camera captures the Gel Card image, which is then transferred to the Raspberry Pi 4B Following pre-processing steps, an aggregated image is produced The algorithm analyzes the height of the condensation columns to infer results, which are subsequently displayed on the user interface.
3.4.3 A flowchart of agglutination level and blood type
Figure 3 13 A flowchart of agglutination level and blood type a) Image pre-processing
The image processing procedure involves several key steps: first, the image is cropped and converted from RGB to HSV color space Next, a red threshold is established in the HSV spectrum to isolate red regions, which are then converted to grayscale This grayscale image is transformed into a binary format using thresholding techniques Following this, the binary image undergoes dilation with a 5x5 kernel, allowing for the calculation of the midpoint of the dilated area Finally, the agglutinate level of the gel column is determined based on the vertical coordinates of this midpoint.
The camera image will be divided into eight individual images, each featuring a Gel Card, with dimensions of 255x75 pixels To identify the necessary cutting coordinates, we utilize Paint software on Windows As illustrated in Figure 3.14, the specific areas to be extracted from each micro tube are highlighted.
Figure 3 14 Image area is cropped in Gel Card (red border) roi1 = img1[274:274+255,423:423+75] roi2 = img1[274:274+255,583:653] roi3 = img1[274:274+255,708:708+75] roi4 = img1[274:274+255,855:855+75] (4.1) roi5 img1[274:274+255,1002:1002+75] roi6 = img1[274:274+255,1145:1145+75] roi7 = img1[274:274+255,1289:1289+75] roi8 = img1[274:274+255,1427:1427+75]
Figure 3 15 The result after image cutting in Gel Card Reader
Step 2: Convert RGB to HSV image
The standard RGB color space is often inadequate for effective color recognition To address this limitation, we utilize the HSV color space, which is derived from RGB In Python, the OpenCV library facilitates the conversion of RGB images to HSV format with the following function: hsv1 = cv2.cvtColor(roi1, cv2.COLOR_BGR2HSV).
Note: hsv1: HSV image after convert from RGB image roi1: RGB image
Figure 3 16 RGB to HSV diagram
Figure 3 17 Results after converted image from RGB to HSV
We analyzed data samples from multiple Gel Cards, focusing on the degree of agglutination By classifying the Hue, Saturation, and Value (HSV) parameters of the agglutination regions, we established specific thresholds to effectively filter out red areas for subsequent processing.
Figure 3 18 The selectable color threshold for filtering
Once you have defined and filtered the desired color area, the next step is to apply the threshold method to convert the grayscale image into a binary image.
G(x,y) The function converts a gray image to a binary image using the threshold method: gray1 = cv2.cvtColor(output1, cv2.COLOR_RGB2GRAY) ret, threshold1 = cv2.threshold(gray1, 10, 255, 0)
Note: output1: The Image after processed with red filter
In grayscale images with gray levels ranging from 0 to 255, the thresholding method is applied by selecting a threshold value (T = 10) Pixels with gray levels below 10 are assigned a value of 1, while those with gray levels above 10 are assigned a value of 0.
Figure 3 19 Image after processed with threshold Step 4: Find the midpoint of the binary image area
The cv2.findContours function is essential for identifying the borders of specific areas within an image As illustrated in Figure 3.20, after processing the microtube image, we utilize cv2.findContours to detect the edges of the white binary image and subsequently draw these contours.
Figure 3 20 Determine binary image area and draw contour.
Then we use the function cv2.moment to find the midpoint of the image area, applying the following formula.
C y =M 01 /M 00 total_contours = len(contours) print('Total: ',total_contours) locations = [] for contour in contours:
M = cv2.moments(contour) cX = int(M["m10"] / M["m00"]) cY = int(M["m01"] / M["m00"]) print('center on the x-axis :',cX,' center on the y-axis',cY) locations.append([cX,cY])
E.g Determine the center point of binary image in Gel Card’s microtube.
Figure 3 21 The value belong x and y axis of center point in binary image Figure
3.21 show us the value belong x and y axis of center point in Figure 3.20 b) Flow chart determines blood type based on agglutination results of Gel Card Reader
Figure 3 22 Flowchart of blood type determination in Gel Card
The algorithm flowchart for determining blood type using a Gel Card Reader is illustrated in Figure 3.22 After image processing, results are recorded and processed through the blood grouping algorithm The first step is to check the Ctrl column in positions 4 and 8 If either column shows a positive result ranging from 1+ to 4+, the card is deemed unusable, and an error message is displayed on the interface Conversely, if the Ctrl column shows a negative result (-), data is collected from other microtubes labeled A to continue the testing process.
D, then deduce the result Example: Column A has a value of 1 (positive), column B has a value of 0 (m calculated) and column D has a value of 1
The blood type result will be identified as A+, and the user interface provides clear visibility of agglutination levels in the columns, assisting users in detecting both minor and significant abnormalities in antibody presence within the patient's blood.
PRINCIPLE OF OPERATION
To begin, connect the power circuit to a 220V voltage supply and activate the Raspberry boot switch Once the desktop screen is displayed, locate and click on the Gel Card icon to start the program.
To prepare a Gel Card sample, inject the patient's erythrocytes into microtubes and centrifuge at 1015 rpm for 10 minutes After centrifugation, place the Gel Card in the measurement position of the machine and click the "View Gel Card" button on the interface, allowing the webcam to capture the image The program will then crop and process the Gel Card image, displaying the results in the "View Result" section If the Gel Card is defective or damaged, a message will appear stating, "Wrong Gel Card, please use another Gel Card!"
CONNECTION OF SYSYTEM PARTS
INTRODUCTION
The application of image processing in medical diagnostics has led to the development of a Gel Card Reader for blood grouping tests, which analyzes the agglutination position of erythrocytes in microtubes This innovative system includes a user-friendly interface and a model that accurately determines the position of red blood cell agglutination, subsequently displaying the results The Gel Card Reader has gained popularity in major hospitals, enhancing the efficiency and reliability of blood grouping tests.
The project is built with a small system model, low capacity, only suitable for clinics or small and medium hospitals.
POWER SUPPLY
4.2.1 Assembly of the Power Supply
Steps to conduct circuit construction:
List components, make the schematic on Proteus software.
Make the printed circuit board (PCB), arrange components on the printed circuit board in Proteus software, export pdf file.
Printing the PCB on a glossy paper, position it on the copper board, ironing it After that, wash the circuit with ferric chloride.
Conducting drilling, arranging the components on the board, and soldering it.
Plugin the power, recheck the circuit, and measure the outputs of the source board.
4.2.2 Execution of The Power Supply
The power supply board's PCB (Printed Circuit Board) is designed using Proteus 8.6, followed by simulation testing to obtain precise results The components utilized in the design are detailed in Table 4.1.
Table 4 1 Electronic component of the switching power supply board
DEPARTMENT OF ELECTRONIC – BIOMEDICAL ENGINEERING 38
Next, the PCB is designed in Proteus software and constructed Figure 4.1 describes the PCB of the switching power supply.
Figure 4 1 The top side (a) and bottom side (b) of PCB
Figure 4.2 describes the completed power supply There are two 5V-2A header output and one USB power port.
Figure 4 2 The 5 Volt switching power supply
4.2.3 Inspection of The Power Supply
After assembling the power supply, we meticulously check all outputs to confirm they deliver sufficient voltage and current for the project's modules As illustrated in Figure 4.3, the inspection process ensures that the power supply board meets the required voltage specifications.
Figure 4 3 The inspection output voltage of power supply board
EXECUTION THE CASE OF GEL CARD READER
A Gel Card Reader case was successfully created using a 3D printer, with all enclosure components constructed from PLA material The resulting base holder and Gel Card Reader case are illustrated in Figure 4.4.
Figure 4 4 Base holder (a) and case (b) of Gel Card Reader
SYSTEM CONSTRUCTION
The program interface of the system is divided into three key components: control, display, and results The control section features a Gel Card Reader button with two options for image retrieval: directly from the webcam or from a file The display area shows the captured image, while the results section presents the readable outcomes from the Gel Card This interface is designed using Qt Designer software.
Figure 4 5 Graphic User Interface of Gel Card Reader 4.4.2 Model Construction
● Model Size: Length 24 cm, width 12 cm, height 13 cm.
● The Raspberry Pi 4B is located inside the device.
● Webcam Hoco D101 is used to receive images, the distance from the camera to the location of the Gel Card is 10 cm.
● Use 1 5V 5A power supply circuit as a power supply for the Raspberry Pi Board, USB Led and the heatsink fan.
● 14 inch Samsung LCD screen, keyboard, mouse.
PROGRAMMING SOFTWARE
The team utilized the Python programming language to develop code for their project, as it is the most favored choice for embedded projects with Raspberry Pi For programming, they chose Pycharm as their integrated development environment (IDE) due to its user-friendly interface, ease of use, and efficient data management capabilities.
Figure 4 6 PyCharm IDE for python programming 4.5.2 Image processing program img1 = cv2.imread('C:/Users/Admin/Desktop/gelcard/test7.jpg') roi1 = img1[274:274+255,423:423+75] hsv1 = cv2.cvtColor(roi1, cv2.COLOR_BGR2HSV)
To process a Gel Card image, start by cropping the micro tube 1 area Utilize the provided code to define color ranges for red hues in HSV format, creating masks for both lower and upper red values Combine these masks to isolate the desired region, then convert the result to grayscale Apply a threshold to distinguish features, and use a 5x5 kernel for dilation to enhance the image This method effectively prepares the Gel Card for further analysis.
In this process, we establish two filters to isolate the red areas within each microtube, as detailed in Chapter 3 We utilize the cv2.findContours function to identify contours, employing the RETR_TREE and CHAIN_APPROX_SIMPLE methods The total number of detected contours is then calculated and displayed, while the locations of these contours are recorded for further analysis.
To calculate the centroid of a contour, we use the `cv2.moments()` function, extracting the x and y coordinates as `cX` and `cY` These coordinates are appended to a list called `locations`, which is then sorted based on the x-coordinate For each location in the sorted list, we determine the y-coordinate range to classify the result: if `indexY` is less than 60, we draw a white circle and classify it as 'Positive (4+)'; if between 60 and 70, it's 'Positive (3+)'; between 70 and 80, it's 'Positive (2+)'; between 80 and 95, it's 'Positive (1+)'; and for values above 95, we classify it as 'Negative (-)' and draw a black circle.
After dilate image, we find the center pixel of area, X-axis
Index Y We base on Index Y parameter to determine alggutination level of microtube.
QT Designer is a versatile integrated development environment (IDE) for creating GUI applications using C++, JavaScript, and QML As part of the Qt SDK, it simplifies the development process by utilizing the Qt API to streamline host operating system GUI function calls The IDE features a visual debugger and a WYSIWYG layout designer, enhancing user experience with tools like syntax highlighting and autocompletion On Linux, Qt Creator leverages the GNU Compiler Collection, while on Windows, it supports MinGW or MSVC, and can utilize the Microsoft Console Debugger for source code compilation.
Figure 4 7 Gel Card GUI is built on QT Designer
RESULTS AND DISCUSSION
GENERAL RESULTS
After three months of extensive research on professional documents and online resources, along with valuable guidance from our lecturer, we successfully completed the project titled "Design of a Gel Card Reader for Blood Grouping Tests." This project was finished on schedule and met all specified requirements.
Research and understand the principle of operation of the webcam, Raspberry
Design and build the model hardware with full essential functions, reasonable layout, and stable operation.
Learn, design, and create GUI.
Design a switching power supply for stable output voltage.
Research and understand algorithms and functions and the light environment conditions applied to the processing, calculating and giving results, and identifying defective samples.
Building a system capable of managing patient information, making it easy to access data.
ACHIEVEMENT RESULTS
Figure 5.1 illustrates the arrangement of input jacks, output jacks, and components, highlighting the power supply's capability to deliver a maximum of 25W Notably, the power supply port remains cool even after extended use.
Figure 5 1 Input, output jacks of the switching power supply.
The output voltage of the power supply is set at 5V, adjustable between 4.8V and 5.2V using a 1 Kohm potentiometer in the voltage feedback circuit In the event of a short circuit, the power supply can disconnect from the 220AC input voltage Designed with a feedback and control voltage circuit, this power supply ensures stable voltage operation within its specified power limits, promoting reliable performance of connected components, as illustrated in Figure 5.2 and detailed in Table 5.1.
Figure 5 2 Measure output voltage when the load is connected.
Table 5 1 Outputs/Inputs voltage of power supply testing
30 minutes after the power supply connected to loads
The team has developed a user-friendly GUI using QT Designer on the Python platform, enabling users to effortlessly manipulate and read Gel Card images while observing and interpreting results in each column Additionally, the interface includes an information entry section for managing sample results, with the initial program launch displaying a clear and organized screen layout.
Figure 5 3 GUI of a Gel Card Reader
Figure 5 4 Gel Card Reader system 5.2.4 Test results
The Gel Card reading method utilizes gel column agglutination to determine blood type results The study was conducted using GRIFOLS Gel Card samples, which are currently employed at Thu Duc General Hospital.
5.2.5 Result of Gel Card Reader
Figure 5 5 Sample is put into Gel Card Reader
The GUI control features a Read key that allows users to capture images directly from the Gel Card Reader, utilizing the appropriate blood grouping card with 8 micro-tubes supplied by GRIFOLS Upon clicking the Read button, the capturing device takes an image and transmits it to the Raspberry Pi 4B for preprocessing, agglutination recognition, and result exportation Results are displayed on the screen within 5 seconds, as shown in Figure 5.6.
The system is able to recognize faulty Gel Card based on agglutination in Ctrl column, if Ctrl column is a positive result, it means that Gel Card is damaged, unusable.
Figure 5 7 Wrong Gel Card recognition
To ensure the system works correctly, the system has been tested many times by different Gel Card models, below are some specific examples.
Figure 5 8 The result interpretation (Sample 1: O- ; Sample 2: B+)
Figure 5 9 The result interpretation (Sample 1: A+ ; Sample 2: B-)
We conducted a series of tests to evaluate the effectiveness of the Gel Card Reader system by applying for samples on November 25, December 16, December 30, and January 18 The results, illustrated in the chart below, compare the performance of the Gel Card Reader system with the DG Reader from GRIFOLS.
Table 5 2 The Accuracy and Efficiency of Gel Card Reader
Figure 5 10 DG Reader of GRIFOLS
Figure 5 11 Gel Card Reader and GRIFOLS’s DG Reader Comparison
The accuracy of the Gel Card Reader, as illustrated in Figure 5.11, ranges from 65% to nearly 90% However, some errors occur during the interpolation process due to certain cards being too lengthy to maintain color consistency at the start Overall, the findings align with the intended goals and requirements established during the selection and implementation of the project.
INSTRUCTION
Step 1: Plug the male jack in the power outlet, connect VGA cable to device, turn on the power switch, plug the mouse and keyboard into USB ports, wait for raspberry booting (10-20 seconds).
Step 2: Click on Thesis Graduation icon on Desktop Screen, put the Gel Card after processing into the tray holder.
Step 3: Press the Read button on the screen, after the results have been displayed, fill the patient information and press Save If you want to print the report, just press the Print button If you want to see all the patient’s results, click on Database on toolbar If you want to exit the program, click the X button on the left top corner then click Exit.
Causing: Put the Gel Card slowly, avoid tilting If you don’t put the Gel Card in the correct way, the result will be affected.
We have developed a compact and portable device specifically designed for reading Gel Cards in blood grouping tests This high-performance product accurately determines blood types and identifies defective Gel Cards, while also managing patient information and allowing for easy access to patient history.
Due to sample size and type limitations, the group was unable to measure all blood types and could only utilize the available Gel Cards based on hospital samples The device is designed to read only the dominant blood type card and does not possess barcode scanning capabilities for the Gel Card Consequently, the group focused exclusively on determining the dominant blood group, as the hospital rarely employs other card types.
FUTURE WORKS AND CONCLUSION
CONCLUSION
The graduation project successfully utilized image processing techniques to read results from Gel Cards, achieving its initial objectives The implemented system model features functions for reading, displaying, saving, and managing results The team effectively applied their knowledge of image processing to develop algorithms, create a user-friendly GUI, design power circuits, and model design through 3D printing The results obtained are characterized by high precision and an intuitive, easy-to-use interface.
FUTURE WORKS
In the process of implementing the graduation project until the completion of the topic, the biggest error belongs to the image processing To improve this problem:
Find the best HSV color filter to read Gel Card.
Apply additional filters to avoid image noise.
To enhance the readability of various Gel Card types, including Forward Reverse, Coombs, and CrossMatch, it is essential to utilize a large and diverse sample set for accurate system evaluation.
[1] Salama Yusuf, “How Were Blood Types Discovered ?”, scienceabc.com, access on 26/10/2020.
[2] Dr Jadhad M V “Gel tech”, slideshare.net , Apr 18, 2017.
[3] Nguyễn Hiền Minh, Phan Thanh Phong, “ỨNG DỤNG XỬ LÝ ẢNH TRONG
HỆ THỐNG PHÂN LOẠI SẢN PHẨM”, Graduation thesis in HCMUTE, 6/2019.
[4] Võ Danh Quân, Nguyễn Minh Hảo, “ĐẾM SỐ LƯỢNG VIÊN THUỐC CÓ
TRONG VỈ THUỐC”, Graduation thesis in HCMUTE, 12/2019.
[5] Thiago Carvalho, “Edges and Contours Basics with OpenCV”, pyimagesearch.com, Jul 20, 2020.
[6] Nguyen Thanh Huy, “ỨNG DỤNG PHƯƠNG PHÁP PHÁT HIỆN BIÊN
TRONG NHẬN DẠNG CÁC ĐỐI TƯỢNG HÌNH HỌC”, Master thesis in Universiy of Da Nang, 2018.
[7] Nguyen Phuc Bao, Nguyen Le Gia Bach , “DESIGN OF AN ACQUISITION
IMAGE SYSTEM FOR THE DETECTION OF OCCLUSAL DENTAL
PROBLEMS”, Graduation thesis in HCMUTE, 8/2020.
[8] Lê Hoàng Thành, Hồ Đình Vương, “THIẾT KẾ VÀ THI CÔNG HỆ THỐNG
BẢO MẬT ỨNG DỤNG XỬ LÝ ẢNH”, Graduation thesis in HCMUTE, 7/2019.
[9] Apogeeweb, “Switching Power Supply Circuit Diagram with Explanation”,apogeeweb.net, 13 Jul 2019.
The main program code utilizes PyQt5, importing essential modules such as QtCore, QtGui, and various components from QtWidgets Key functionalities include the use of QMainWindow for the main application window, QFileDialog for file selection, and QMessageBox for displaying messages to the user.
QLabel, QTextEdit, QWidget, QVBoxLayout from PyQt5.QtGui import QPixmap from PyQt5.QtGui import QTextCursor from PyQt5.QtPrintSupport import QPrintDialog, QPrinter from PyQt5.uic import loadUi from butterworth import
The provided code snippet demonstrates a Python class named `LoadQt`, which inherits from `QMainWindow` It initializes the user interface by loading a UI file and sets a custom window icon The class contains a placeholder for an image and connects a button click event to a method that opens an image file.
The code snippet connects various actions to their respective functions, such as opening an image and displaying author information It initializes a QTextEdit widget and sets a background image for a label using a specified logo Finally, it applies a main layout to the user interface.
@pyqtSlot() def loadImage(self, fname): self.image = cv2.imread(fname) self.tmp = self.image self.displayImage(fname) self.ReadGelcard() def Giaodien(self): fname, filter = QFileDialog.getOpenFileName(self, 'Open File',
To load an image in a PyQt5 application, the `open_img` function utilizes `QFileDialog` to prompt the user to select a file Upon selection, if the file name is valid, the `loadImage` method is called; otherwise, an "Invalid Image" message is printed The `displayImage` function is responsible for displaying the loaded image, determining the appropriate QImage format based on the image's shape It checks if the image has an alpha channel and sets the format accordingly The image is then converted to a QImage, its color format is adjusted using `rgbSwapped`, and it is displayed in a QLabel centered within the window.
"Image Files (*)") if fname: self.loadImage(fname) else: print("Invalid Image")
# cv2.destroyAllWindows() def save_img(self): fname, filter = QFileDialog.getSaveFileName(self, 'Save File', 'C:\\', "Image Files
(*.png)") if fname: cv2.imwrite(fname, self.image) # Lưu trữ ảnh print("Error") def AboutMessage(self):
QMessageBox.about(self, "About Qt - Qt Designer",
"Qt is a multiplatform C + + GUI toolkit created and maintained byTrolltech.It provides application developers with all the functionality needed to build applications with state-of-the-art graphical user interfaces.\n"
"Qt is fully object-oriented, easily extensible, and allows true component programming.Read the Whitepaper for a comprehensive technical overview.\n\n"
Since its launch in 1996, Qt has been the foundation for thousands of successful applications globally It is also integral to the widely-used KDE Linux desktop environment, which is included in all major Linux distributions Explore our Customer Success Stories to discover examples of successful commercial development using Qt.
"Qt is supported on the following platforms:\n\n"
"\tSolaris, HP - UX, Compaq Tru64 UNIX, IBM AIX, SGI IRIX and a wide range of others\n"
"\tEmbedded - - Linux platforms with framebuffer support.\n\n"
"Qt is released in different editions:\n\n"
The Qt Enterprise Edition and Qt Professional Edition are designed for commercial software development, allowing for traditional software distribution along with free upgrades and technical support For the most current pricing information, visit the Trolltech website's Pricing and Availability page or reach out to sales at trolltech.com The Enterprise Edition includes additional modules that are not available in the Professional Edition.
The Qt Open Source Edition is accessible for Unix/X11, Macintosh, and Embedded Linux platforms, specifically designed for developing Free and Open Source software This edition is offered at no cost under the Q Public License and the GNU General Public License.
QMessageBox.about(self, "About Author", "Lecturer: Assoc Prof Dr Nguyen
"\t Truong Hoang Gia Bao - ID: 16129007"
) def QuestionMessage(self): message = QMessageBox.question(self, "Exit", "Bạn có chắc muốn thoát", QMessageBox.Yes | QMessageBox.No,
In the process of reading Gelcards, specific regions of interest (ROIs) are extracted from an image, with eight distinct ROIs defined by their pixel coordinates Each ROI is resized to half its original dimensions and converted from BGR to HSV color space for further analysis This systematic approach ensures accurate data extraction and processing for effective image analysis.
To detect red regions in an image, the code utilizes OpenCV to create masks for two ranges of red hues in the HSV color space It combines these masks to isolate the red areas and applies a bitwise AND operation with the original image The result is converted to grayscale, followed by thresholding to enhance features A dilation operation is then performed to strengthen the contours, which are subsequently extracted Finally, the total number of detected contours is printed, along with their locations for further analysis.
To calculate the centroid of a contour in an image, we use the OpenCV function `cv2.moments(contour)` to derive the coordinates `cX` and `cY` These coordinates are then appended to a list of locations The locations are sorted based on the x-coordinate, and we iterate through each location to draw circles on the image Depending on the y-coordinate, we classify the result as positive or negative: if `indexY` is less than 60, it indicates a positive result (4+); between 60 and 70, it's a positive result (3+); between 70 and 80, a positive result (2+); between 80 and 95, a positive result (1+); and greater than 95 indicates a negative result (-) The corresponding classification is displayed in the text browser.
To detect red objects in an image using OpenCV, the code defines two color ranges for red in the HSV color space and creates masks for each range These masks are combined to isolate the red areas in the image The resulting output is converted to grayscale, and a threshold is applied to create a binary image Dilation is performed to enhance the features, and contours are extracted from the dilated image Finally, the total number of detected contours is printed, indicating the number of red objects found.
To calculate the centroid of a contour in OpenCV, we use the moments function: `M = cv2.moments(contour)`, which gives us the coordinates `cX` and `cY` for the x and y axes These coordinates are then appended to a list called `locations` The list is sorted based on the first element using a custom sorting function Depending on the y-coordinate value, circles are drawn on the image with specific color codes, and corresponding positive or negative states are assigned If the y-coordinate is less than 60, it indicates a positive result of 4+; between 60 and 70, it’s 3+; between 70 and 80, it’s 2+; between 80 and 95, it’s 1+; otherwise, it signifies a negative result Each result is displayed in a text browser for clarity.
The code snippet processes an image to detect red regions using color masking It defines two ranges for the red color in HSV format and creates masks for each range These masks are combined to isolate red areas in the image The output is converted to grayscale, and a threshold is applied to enhance the features Dilation is performed to strengthen the contours, which are then identified using the findContours function Finally, the total number of detected contours is printed, along with the initialization of a list to store their locations.
To calculate the centroid of a contour, we use the OpenCV function `cv2.moments(contour)`, which provides the coordinates `cX` and `cY` These coordinates are then appended to a list of locations The locations are sorted based on the x-coordinate using a custom sorting function For each location, we determine the corresponding indexY value and draw a circle on the region of interest (roi3) based on its vertical position If indexY is less than 60, it indicates a positive result (4+), while values between 60-70, 70-80, and 80-95 correspond to positive results of 3+, 2+, and 1+, respectively Any indexY value above 95 results in a negative outcome The results are displayed in a text browser, indicating the positivity or negativity of the test.