Hrev_master Healthcare in Low-resource Settings 2024; volume 12:11811 Development of a food detector using image processing through camera sensor innovation Adriyani Adam,1 Hijrah Asikin,1 Agustian Ipa,1 Sahrir Sahrir,2 Ali Imran3 1Department of Nutrition, Politeknik Kesehatan Kementerian Kesehatan, Makassar; 2Electrical Engineering, Politeknik Negeri Ujung Pandang, Makassar; 3Institut Ilmu Kesehatan Pelamonia, Makassar, Indonesia Abstract Indonesia is currently struggling with stunting, wasting, obe- sity, and micronutrient deficiencies. Nutritional imbalance, which varies by gender, age, and activity level, contributes to these issues. This research developed a food detector with an innovative camera sensor to accurately measure food calories. The study adopted a developmental approach, using a pre-experimental design and “post-test only” research. The study included various food ingredients with calorie counts. Camera sensors were used instead of load cell sensors to weigh food and convert it to calo- ries. Camera sensory testing was done on processed food samples. A number of food image data tests showed high accuracy. With test results close to real data, the device showed promising accu- racy. This model system used camera resolution to detect calories, helping people measure and manage their diets in quality and quantity. We hope this technology will continue to improve, mak- ing it more accessible and aiding nutritional management. Introduction Food is a fundamental necessity for survival in daily life. It provides the energy required by the body for activities and metab- olism, enabling the maintenance of health and proper bodily func- tion.1 The calorie content of food varies across different types, as does the quantity consumed by individuals.2,3 However, in modern times, excessive food consumption has become prevalent, con- tributing to the steady rise in global obesity rates.4 In 2022, approximately 2.5 billion adults aged 18 and over, were over- weight, with around 890 million adults classified as obese. This equates to 43% of adults worldwide being overweight and 16% being obese. Alarmingly, over 1 billion people globally, including 159 million children and adolescents aged 5-19 years, are current- ly living with obesity. The prevalence of obesity among children and adolescents has surged from 2% in 1990 to 8% in 2022. Several factors drive this excessive food consumption, including negative emotions, exposure to enticing foods, difficulty in con- trolling food intake, lack of satiety, cravings, and even food addic- tion.5 To combat this trend, exercising self-control in food con- sumption is crucial. The trend of these cases might also lead to a double burden of non-communicable diseases.6 One effective strategy is to measure the calorie content of the food being con- sumed, enabling individuals to make informed dietary choices and maintain a healthy balance in their nutrition. A calorie measuring device is a measuring instrument used to calculate the amount of calories in each food, with the aim of enabling people to choose healthy food for their bodies. Measuring calories and nutrition in daily food is a challenging method.7,8 A system that can measure calories and nutrition in daily food can help patients and nutritionists measure and manage the amount of food intake. There are various ways to measure food calories to determine the calorie content of the food, includ- ing manual methods and using digital tools. Manual calorie calcu- lations in food can be done by using measuring scales and meas- uring cups to measure the portion size of calories in food and by using comparisons9. However, manual calculations are still not Correspondence: Adriyani Adam, Department of Nutrition, Politeknik Kesehatan Kementerian Kesehatan, Makassar, Indonesia. E-mail: adriyani@poltekkes-mks.ac.id Key words: food detector; macronutrients; micronutrients. Acknowledgments: we would like to thank the Health Polytechnic of Makassar for their valuable insights and contributions to this study and the contribution of the mentoring program conducted by the Research Centre of Excellence in Advancing Community Health, Surabaya, Indonesia. Contributions: AA, HA, SS, conceptualization; AA, SS, data curation, formal analysis, visualization, writing – original draft; HA, investigation; AA, HA, SS, methodology, validation; AIp, resources, supervision; AIp, AIm, writing. All the authors participated in the review and editing of the paper and approved the final version to be published. Conflict of interest: the authors declare no potential conflict of interest. Funding: this research was supported by the Health Polytechnic of Makassar and did not receive external funding. Ethical approval and consent to participate: the research has received eth- ical approval from the Health Polytechnic of Makassar Ethics Commission. The Ethics Commission of the Health Polytechnic Makassar, with regard to the protection of human rights and welfare in medical research, has carefully reviewed the research protocol entitled number: 175/KEPK-PTKMS/IV/2022. Availability of data and material: all data generated or analyzed during this study are included in this published article. Informed consent: written informed consent was obtained for anonymized patient information to be published in this article. Received: 14 September 2023. Accepted: 11 June 2024. Early access: 24 June 2024. This work is licensed under a Creative Commons Attribution 4.0 License (by-nc 4.0). ©Copyright: the Author(s), 2024 Licensee PAGEPress, Italy Healthcare in Low-resource Settings 2024; 12:11811 doi:10.4081/hls.2024.11811 Publisher's note: all claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organi- zations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher. [Healthcare in Low-resource Settings 2024;12:11811] [page 491] Non -co mmerc ial us e o nly efficient and effective. Therefore, the development of digital meas- uring devices is expected to overcome these problems. Digital calorie measurement devices that currently exist in the community are still mainly utilized by certain groups such as nutri- tionists in hospitals and health laboratories. This is due to the need for specialized knowledge to operate the device, which limits its usage among the general public. Furthermore, these devices are still expensive and not affordable for average people. In addition, the size of the device is still too large as it still uses load cell sensor principles. The amount of calories in food is needed to calculate energy balance. Excess calories will be stored as fat. Excessive fat accumulation can increase the risk of hypertension, obesity, heart disease, stroke, and diabetes. Therefore, calorie intake needs to be controlled to maintain body balance and prevent metabolic dis- eases, which are medical conditions related to energy production in human cells, one of the well-known metabolic diseases with many sufferers is diabetes mellitus.10 The development of the food detector uses an Arduino Uno, Arduino shield circuit, button circuit, load cell sensor, LCD, Bluetooth HC-05, Pixy CMUcam5 camera, Android smartphone, and power supply circuit. Android sends data to Arduino to instruct the Pixy CMUcam5 camera to detect food and then output the amount of calories and nutrients. Arduino processes the load cell work to detect food, and the amount of calories and nutrients con- tained in each food can be determined. The measurement results data will be sent to the Android smartphone for analysis, and the analysis results will guide each user to pay attention to their eating patterns. The purpose of the study was the development of a sys- tem that can identify and classify food items using image process- ing techniques and advanced camera sensors. Materials and Methods Research design This research employed an experimental study design with a quantitative approach. A camera-based food detection system will be developed and tested to measure its accuracy under various real- world conditions. This study used a developmental approach that employed a pre-experimental with a “post-only design” research type. In this study, camera sensors were used as a substitute for load cell sensors, and image processing was applied to determine the weight of the food, which was then converted into calorie values. Sample Food images of various types, shapes, and presentations were used as samples in this research. Sample images were obtained from public datasets and a collection of food images was created specifically for this research. This study went through several stages. The first stage was the initial stage in the development of a food detector, which was to detect the number of calories through a sensor system. Samples of processed food were used and then applied to the camera sensory system. Data analysis The stages in this food nutrition detection system are as fol- lows: i) image input using a camera. At this stage, the camera cap- tures an image of the food. The results of the image capture are then processed to obtain the required parameters; ii) image seg- mentation. This process separates the food object from the back- ground and it’s useful for setting boundaries so that area and height calculations are more accurate; iii) calculation of image area and height. Calculating the area and height is useful for obtaining the volume value of the food. The area and height calculation is done using the region props class; iv) calculation of food calories. The calorie calculation utilizes the volume calculation results from the previous stage. Method of calculating food calories To calculate the calories contained in food, the calorie calcula- tion formula is used: Calories = (energy/100) ´ food mass The energy contained in the food has been statically inputted into the program. There are three different types of food, namely white rice, fried rice, and red rice. Each type of food has a different calorie value per 100 grams. The food mass is obtained from the calculation of the height and width of the food image obtained. Height multiplied by width will obtain the volume. The volume is then multiplied by the mass density to obtain the mass of the food image. Results Based on Table 1, a comparison of the measurement results from the camera sensor with the Indonesian food composition table (TKPI) can be seen. The results of the evaluation of these Transforming Healthcare in Low-Resource Settings: A Multidisciplinary Approach Towards Sustainable Solutions [page 492] [Healthcare in Low-resource Settings 2024;12:11811] Table 1. Sample testing results using a camera sensor. Testing Type of food Types of units Results TKPI Weight 10 gr 50 gr 100 gr 10 gr 50 gr 100 gr Sample A Mass 9.82 51.24 100.91 - - - Calories 17.69 92.23 181.65 18.00 90.00 180.00 Volume 13.05 94.04 313.94 - - - Sample B Mass 9.83 49.80 100.57 - - - Calories 14.66 74.20 149.86 14.90 74.50 149.00 Volume 13.06 87.66 312.43 - - - Sample C Mass 10.09 51.47 101.23 - - - Calories 25.23 128.68 253.08 25.00 125.00 250.00 Volume 13.40 95.06 315.32 - - - TKPI, Indonesian food composition table. Non -co mmerc ial us e o nly food samples meet the protein adequacy standards set by the TKPI. Testing was carried out using a camera sensor to measure several important parameters of the food samples, including mass, calo- ries, and volume. These measurement results are given in a table for each food sample (Samples A, B, and C) at three different weights: 10 gr, 50 gr, and 100 gr. The results of measuring mass, calories, and volume approach or exceed the TKPI values, so it can be considered that the food has a protein content that meets the expected nutritional standards. Discussion Currently, the measurement of calorie intake in food relies on conventional methods, which calculate the calories needed for daily activities and those consumed. However, this study intro- duces a novel approach utilizing image processing methods for calorie measurement.11 This method involves recognizing the object to be measured, determining its volume, and analyzing its contour shape. The objective of image processing in this study is to enhance the quality of images. During testing, a webcam with a resolution of 480p was employed to mitigate issues such as low color contrast, blurriness, and white spots or noise in the images. Initially, adjustments were made to the camera’s height to optimize the distance between the object and the capturing camera, as this significantly impacts the accuracy of calorie detection. Once adjusted, the camera was placed 40 cm away from the object. The calorie detection model was implemented using MATLAB soft- ware. MATLAB is a high-performance software that integrates computation, visualization, and programming for mathematical notations. This software detects calories in food and operates on a laptop/computer connected to a webcam.12 Accuracy testing in a developed system can be defined as the degree of closeness between the measured values and the true or real values. If there is no actual data or considered correct value in the accuracy testing of a system, it will not be possible to deter- mine how accurate the measurement of the system is. Accuracy is defined as the difference value or the closeness value between what is read by the measuring device and the true value. The accu- racy testing of this food detector was carried out twice using three types of rice, which were then compared with the real nutritional data values in the TKPI for the year 2017 to obtain more accurate results. After preprocessing the input image, image segmentation was carried out to separate the object from the background. RGB color segmentation was used, which would be divided into two clusters (one can choose which cluster would provide the best sep- aration of an object from the background), then the area and height of the image were calculated to obtain the volume, which is area ´ height. Using the object’s volume, the mass of the object can be determined using the mathematical equation mass = density/spe- cific gravity ´ volume. Since the object’s weight taken using a cam- era is still affected by gravity, the weight of the object needs to be calculated using the equation weight = mass ´ gravity. After obtain- ing the weight of the object, automatic nutritional value calculation is performed by the MATLAB editor, and this predicted nutritional value is compared with the national reference value. For example, for 10 grams of white rice, 18.69 calories were obtained based on the calorie detection results, while the real value for 10 grams of white rice was 18.00 calories. This shows that the calorie detection results are not significantly different from the real values. Furthermore, the research conducted bears similarities with this study in that it aims to obtain the calculation of calories after obtaining the weight of food, which is done by designing a nutri- tion counting tool in the form of a scale that can measure the weight of food.9 Measuring the weight of food results in the nutri- tional content value of a food item. This tool is equipped with two load cells connected to the HX711 module to measure the weight of the food. Arduino processes the signals generated by the HX711 module, producing a weight value. The weight value is displayed on the LCD and sent to an Android application using Bluetooth connectivity. The calculation of food nutrition is done in the Android application based on the obtained weight value. This tool design yields an average accuracy rate of 98.441% for load cell-1 and 96.974% for load cell-2. The tool has a tolerance value of 1.61% for load cell-1 and 2.69% for load cell-2. The precision level of load cell-1 is 97.93% and the precision level of load cell- 2 is 97.83%. The research conducted differs in terms of classification because it uses convolutional neural network (CNN) modeling, and the device uses a designed application data set.13 Therefore, when taking a picture, the device will display the nutritional con- tent based on the data set that has been designed in the training model and display the name/type of the food. In contrast, the calo- rie detection in this study uses a systematic formulation to obtain the calorie content of a food. The advantage of this study is that there is no need to take a data set, which can be time-consuming as it requires collecting 1000 food data sets of the same type and labeling the images more accurately. Additionally, the calculation of calories is heavily influenced by the weight of the food, so it should be configured first with a scale. The research conducted used the k-nearest neighbor (kNN) method and a load cell sensor to read the measured weight of the food.14 The system captures the image and reads the measured weight of the food through a camera module and load cell sensor. The image is then processed to extract the color value from the mean HSV (hue, saturation, value). The extracted results are then used as features to identify the type of food and measure its calorie content based on the identification results and load cell sensor measurements. The results of the system are displayed on a 16×2 LCD screen. The identification process uses the kNN method based on 75 training data with 5 classes consisting of white rice, red rice, beef rendang, sautéed water spinach, and fried tempeh. Using a k value of 3 in the kNN method results in the highest accu- racy of 96%. In contrast, our study does not use the kNN method based on training data in the system, as the food detector is intend- ed to detect the calorie content of the food rather than classify it. Food calorie detection system has many benefits and potential applications, but there are several limitations to consider in this research. While this system can provide accurate estimates of the number of calories in food, there is still the possibility of errors or uncertainty in the measurements. The accuracy of this system depends heavily on the quality of the images captured and the algo- rithms used to analyze them. Therefore, further validation of the accuracy and consistency of the results is necessary. Conclusions The food calorie detection system holds significant promise for various future applications across different sectors. Individuals seeking to monitor their calorie intake for weight management or health reasons could benefit greatly from this system. By simply capturing images of their meals using a smartphone or dedicated device, users can obtain accurate calorie information in real time. Transforming Healthcare in Low-Resource Settings: A Multidisciplinary Approach Towards Sustainable Solutions [Healthcare in Low-resource Settings 2024;12:11811] [page 493] Non -co mmerc ial us e o nly This can empower individuals to make more informed dietary choices and adhere to their nutritional goals more effectively. In healthcare settings, the calorie detection system could be integrat- ed into dietary assessment tools used by nutritionists, dietitians, and healthcare professionals. This would streamline the process of analyzing patients’ dietary intake, facilitating more personalized nutrition recommendations and treatment plans. References 1. World Health Organization. Healthy diet. 2024. Available from: https://www.who.int/initiatives/behealthy/healthy-diet 2. Diana R, Martianto D, Baliwati YF, et al. Food waste in Indonesian hospitals: a systematic review. Nutr Food Sci 2022;53. 3. Mahmudiono T, Rachmah Q, Indriani D, et al. Food and bev- erage consumption habits through the perception of health belief model (grab food or go food) in Surabaya and Pasuruan. Nutrients 2022;14. 4. Puspikawati SI, Kertia N, Purba M, et al. If I like it, I’m eating it: Study of high-calorie high-fat food preference among obese police officer. Ann Trop Med Public Heal 2020;23:1271-8. 5. Laughlin M, Cooke B, Boutelle K, et al. Neuroimaging and modulation in obesity and diabetes research: 10th anniversary meeting. Int J Obes 2022;46:718-25. 6. Arifin H, Chou KR, Ibrahim K, et al. Analysis of modifiable, non-modifiable, and physiological risk factors of non-commu- nicable diseases in Indonesia: evidence from the 2018 Indonesian basic health research. J Multidiscip Healthc 2022;2203-21. 7. Charbonnier L, Van Meer F, Johnstone AM, et al; and PAMS. Neuroimage effects of hunger state on the brain responses to food cues across the life span. Neuroimage 171 2018;246-55. 8. Mulia SA. Work fatigue based on workload and calories intake in several food makers. Indones J Occup Saf Heal 2019;8:158. 9. Agsa F, Putra HFTS, Nugraha R. Perancangan Alat Hitung Nutrisi Makanan Berbasis Arduino Uno. In: eProceedings of Engineering 2021. 10. Riyono A, Tinduh D, Othman Z, Herawati L. Moderate inten- sity continuous and interval training affect visceral fat and insulin resistance model in female rat exposed high calorie diet. Comp Exerc Physiol 2022;18:403-11. 11. Prihaningtyas RA, Widjaja NA, Irawan R, et al. Dietary intakes and high sensitivity CRP (hsCRP) in adolescents with obesity. Carpathian J Food Sci Technol 2019;11:83-8. 12. Yudha WW, Rulaningtyas R, Rahmatillah A, Septanto H. The study of satellite dynamics with reaction wheel actuator and comparison of its numerical solutions using MATLAB/Simulink. In: AIP Conference Proceedings. AIP Publishing; 2024. 13. Dandi M, Hilman Fauzi TSP, Rizal S. Implementasi Algoritma Yolo Pada Aplikasi Pendeteksi Citra Makanan Berbasis Android. In: eProceedings of Engineering; 2021. 14. Achlison U, Suhartono B. Analisis Hasil Ukur Sensor Load Cell untuk Penimbang Berat Beras, Paket dan Buah berbasis Arduino 2020;13:96-101. Transforming Healthcare in Low-Resource Settings: A Multidisciplinary Approach Towards Sustainable Solutions [page 494] [Healthcare in Low-resource Settings 2024;12:11811] Non -co mmerc ial us e o nly