Detection of fake shallots using website-based haar-like features algorithm

Received June 14, 2021 Accepted July 5, 2021 Published November 30, 2021 Shallots is commonly used as essential cooking spices or complement seasoning. The high market demand for this commodity has triggered some people to counterfeit it. They mix the shallots with defective products of onions to get more benefits. It urges to provide a system that can help people to distinguish whether the shallot is original or fake. This research aims to provides an object recognition system for fake shallots utilizing the Haar-Like Feature algorithm. It used the cascade training data set of 59 positive images and 150 negative images with 50 comparison images. The identification process of the shallots was through the haar-cascade process, integrated image, adaptive boosting, cascade classifier, and local binary pattern histogram. This system was made based on the Django website using the python programming language. The test was conducted 30 times on Brebes shallots mixed with Mumbai's mini onions in a single and mixture test method. The test obtained an average percentage of 69.2% for the object recognition of Mumbai's mini onions. Kata Kunci:


INTRODUCTION
Around 2018, markets in most of the traditional market areas of Java Island received an invasion of fake shallots. This shallot comes from India, which entered Indonesia illegally. This fake shallot is actually onions that is the same size of shallots. The difference between mini onions and shallots is in the slices. Onions do not have child part in the onion, it differs with the common shallots, which have onion tillers. The size of Mumbay's onions that are allowed to be imported in is above 5 cm. From the results of an investigation by the Indonesia's Ministry of Agriculture, it was found that at least 70 percent of onions are in each sack of shallots. This triggers opportunities for fraud by mixing onions that are not fit for circulation with other shallots and then being faked as shallots. This case comes in the price of local shallots dropping drastically [1].
Current technological developments in artificial intelligence (AI) one of which is called image processing or commonly called Computer Vision (CV). Computer Vision is a discipline t hat studies the process of extract special features of objects contained in an image or recognizing objects in images and translating them into information [2]. With this CV, the consumers or even ordinary people can get a useful information system to provide information whether the shallots to be purchased are genuine or not.
Many studies have been carried out to recognize an object, including research to identify shallots and onions. The method used is the feature extraction of red, green, blue colors on objects with a neural network and a Gabor filter applied to the Matlab application. The results of testing on 100 test images can be recognized correctly [3]. Apart from the neural network, a similar algorithm is a Haar-Like algorithm, and this algorithm can be used to recognize objects. The advantage of this algorithm is that it can perform the recognition process in real-time [4]. So that object detection can be done directly without having to take pictures first. Several studies on the application of the Haar-Like algorithm to detect objects are real-time motor vehicle object recognition [5]. The results obtained in the test have a percentage above 70% for images of motorcycles, cars, and buses. The speed level of the Haar-Like algorithm reading process can also be shown in research calculating the speed limit of motorized vehicles [6]. In addition, implementing the Haar-Like method with other methods is also possible, including research that combines the Haar-Like Method with the Local Binary Pattern Histogram (LBPH) to recognize a person's face [7]. The recognition process can be done quickly because all input images are converted to gray images before processing. Thus, the object extraction process is only one layer, which shortens the process [8].
Based on previous studies and literature it showed that the Haar-Like algorithm has a good and fast object reading rate. In addition, the recognition process can be done in real-time. So, the method is very suitable to solve the problem of the rise of fake onions circulating in the market. The references from both journals and other relevant media. Until now, no research has been found to distinguish mini onions that are very similar to red onions with real-time, website-based cameras. Moreover, the output results immediately appear in the camera frame at that time. Referring back to the previous research reference, the research which is to detect mini onions by combining the Haar-Like algorithm with the Local Binary Pattern histogram method and carry out in real-time is possible to do. And it is expected to have a reliable performance in recognizing fake shallot, which is very similar to shallots.

RESEARCH METHOD
The research was conducted with some steps, which were requirements identification, knowledge representation, implementation knowledge, and the last step was testing and evaluation. As shown in the Figure 1.

Figure 1 Research Flow
The stage of requirement identification contains the aspects needed in the system before the system can execute the processes. In this case, the requirements identification is built into three aspects: input requirements, process requirements, and output requirements. Input requirements are something needed by the system to process the tasks. Input requirements include positive images, negative images, and cascade datasets. A positive image is an image that contains a fake onion image. A negative image is an image that does not contain an onion image at all.
The onions that will be used as positive images are dark red mini onions bought from the market or store. Then chose the one that was as close as possible to the shallots. The diameter of the selected onion was 2 cm -4 cm. After that, choose mini onions that are very similar to shallots, both in color and shape, then separate them. Then we took a photo of each mini onion with one onion in at least four different positions. The distance between the camera and the object is 15 cm, and the shooting time is during the day at 10 am -1 pm. The camera resolution used is 12 Mega Pixels, with bright day conditions and not cloudy. The photos are then put together in a folder.
As for negative images, it comes from photos of all things in the around places. Try not to use photos of objects that contain colors or shapes resembling onions which makes training data errors. The camera resolution for taking negative images is still the same, namely 12 Mega Pixels. Then the p hotos are put together in a separate folder with the positive images folder.
The positive image used in this stage is 59, and the negative image used is 150 images. This image yet meets the requirements as an input image, and it is necessary to do some editing on it. The purpose of this editing process is to make the process of taking features from the image can be better, and the process is faster without changing the input. The stages in this editing process include the editing process to remove the background, the editing process to change the image pixel size, and the editing process for the cutting process is focusing on the ROI of the object only. It is intended that the feature extraction process can focus more on the object only. There is no interference from the background or other parts of the image.
The process of removing the image background and the editing process of cropping the object ROI is implemented only on positive images, not negative images. However, the editing process to change the pixel value of the image is implemented on the two input images. The pixel value used in this process is 300x400 px. Then all negative and positive images will experience this process. The input requirements are ready at this stage, and the feature data collection process can be implemented.
The initial stage in making this dataset is to convert the color of all existing images into a grayscale image. The purpose of this conversion is to make it easier to capture image features with only one layer, different from a color format that has at least three channels. In addition, the time required to implement the process also becomes shorter. Furthermore, all existing images, both negative and positive, are executed by a haar-like process. The process of making this cascade dataset is as shown in the flowchart ( Figure 2). In the stage of haar-like process, it will be processed using four steps, namely haar-like features, integral images, adaptive boosting, and cascade classifier. As shown by the Figure 3  The haar-like feature is the process of extracting lines and edges in the image. All existing pictures will be convoluted with haar-like features. The size used in this research is 20x20, so that the convolution process will move from the top left to the right with a box size of 20x20 pixels. This picture below is the haar-like feature used in this process [8]: After the haar-like feature process, the next step is the integral image process to the images. Integration means adding small units together. In a small unit image that is added is the pixel value, the integral value for each is the sum of all pixels from the top left corner to the bottom right [8]. The picture below is a flowchart of the integral image process:

Figure 5 Integral Images Concept
Based on the image above, the left image is an integrated value on the pixel axis (x, y) containing the sum of all pixels in the rectangular area starting from the top left to the location of the axis (x, y). To get the pixel value in the shading area, it is done by dividing the value of the axis (x, y) in the shading area [10].
The next step is the adaptive boosting process (AdaBoost). Boosting assumes the availability of a weak learning algorithm, which is given a labeled training example, resulting in a basic or weak classifier. The purpose of boosting is to improve the performance of a weak learning algorithm while treating it as a "black box" that can be called repeatedly, like a subroutine, but whose interior cannot be observed or manipulated. From this, what can be assumed is that a weak classifier is not completely meaningless in the sense that the error rate is at least slightly better than the random classifier [11].
The Cascade Classifier stage is an image classification process based on the number of features that match a given filter and classified whether it includes objects or not. When the compared image values have a similar pattern, the same pattern area will be cascading. In general, this process is the creation of an area box which will later be processed for the recognition and labeling process [12]. After all the stages are passed, the results of the data obtained will be converted into a dataset with XML format. Then we will immediately test the finished cascade data to see the level of performance in recognizing fake shallot objects. The picture below is the flowchart of testing the dataset cascade.xml that have been create before: After the identification stage is complete, the next stage is the stage of identifying process requirements. In this stage, a follow-up process was carried out from the input requirements stage. In this stage, the dataset cascade was created but with a different value. In this case, the image data that is processed is only positive images. The images size is 300x400 px, same as with the positive images used in the requirement process to make file cascade.xml. the compared images in this stage using 50 images with the different position object at all. The extraction process refers to the previous cascade.xml file. The area considered a fake onion by cascade.xml, the histogram value of the image will be calculated. This process is called the local binary pattern histogram (LBPH) process. The process also calculates the image histogram value as a feature compared with the image list features in the haar-like feature. The main character of object recognition with this method is the composition of the micro -texture-pattern, which is a nonparametric operator that describes the local spatial layout of the image [7]. The data obtained will be converted into a file with an XML extension with the name training.xml. as described in the flow of steps below: Identification of output requirements is the need to process various things made in the input requirements and process requirements. The things that have been made in the previous process include the cascade.xml dataset and the training.xml dataset, which will then be processed and extracted to produce output. The steps performed here are as described in the following flowchart:

Figure 8 Recognition Shallots Recognition
Several parameters were used to recognition system test, including the distance between the camera and the object is about 15-30 cm. The camera used in this test is different. The camera used in this testing phase has a resolution of 5 MP and video Resolution: 1920 x 1080. The position of the object's surface is as clear as possible without being blocked by other objects or covered by more than 1/3 of the part. Tests are carried out with adequate lighting or at least during the day or if at night try to have sufficient lighting.

RESULT AND DISCUSSION
This part is the result of implementing the system based on the design that has been made previously. The input data discussed earlier are negative and positive images. The following displays the need for input images that have undergone a repair process a s described earlier on the left are positive images. As shown in Figure 9. where the steps taken are removing the background and cutting the object's ROI. After that, change the image size to 300x400 px. All positive images that are ready will be collected in one folder. It should be noted that the more variations in the position and shape of the fake onion image, the better the reading will be. After the preparation step of the positive image is ready, the next step is to prepare the negative image as training material. Several stages of editing the negative image are also needed, but not as much as the positive image. The following is a display of negative images that have been done a repair process:

Figure 10 Negative Images
The picture above is a sample display of negative images that have been done in the editing process. The editing process that occurs is resizing the image to a size of 300 x 400 px, the same size as the positive image below. After the two input requirements are ready, the next step is to perform the feature extraction process from the two input images. Before the data is processed, all negative and positive images are converted to black and white. After that, the feature-taking process can be implemented on the amber object. The steps take the dark-light feature values with haar-like features from the top left to the bottom right by matching the values according to the feature masking. As in the figure below: Figure 11 Haar Like Feature Process COMPILER Then after we get the value of the masking process with the haar-like feature mask is obtained. The next step is to implement an integral process on that value. This stage aims to implement an integral process on the image pixels by increasing the image value at a certain point with the pixel values on the left and above. After the process of adding pixel values is complete. The next step is to calculate the value of the dark and light areas passed by the masking haar-like feature by adding up the average pixel value of the black area minus the number of average pixel values for the white area to obtain a new value. If the value obtained is far from one, it can be interpreted that the haar-like feature masking is not similar to the character of the image composition. However, if the value is close to one, it can be interpreted that the pixel arrangement is following the haar-like feature masking and will be marked as the part that is close to appropriate.
From the pixel position that has been identified on the stage of the integral image, and then it will be processed with the Adaptive Boosting (AdaBoost). This process is aims to group the characteristic values that have been obtained at the integral stage into several classes according to the data features. Then the class division will be carried out, and each class member will be identified regarding the number of members that do not match. Each member who does not fit the class will be considered a weak member, and each weak member will be added to the new weight. Then do the Adaptive Boosting process again. Up to the smallest error value. As explained in the Figure 12.

Figure 12 Adaptive Boosting Process
The red color is assumed to be fake shallots, and then the green one is supposed to be another object. The first step is to divide the set into two parts and classify it. Stage 1 was divided as shown in stage 1, and it was found that in the red class 2, classification errors were found, and in the green class 1 misclassification was found. The next stage is stage 2, where the wrong member in each category is added to the new weight, as shown in stage two, and classified into two different classes. And the result is that the red class has two errors, and the green class gets one error so that the wrong member in each category is added to the new weight again. Then at stage 3, the class division is carried out, as shown in the picture stage 3. There is only one error found in the green class, namely one error.
After the smallest error value is obtained, the cascade classifier process can be carried out. This process is classified based on the number of masking haar-like features that match the pixel values in the image. This stage is carried out many times by comparing the haar values in each classification, starting from the smallest match value to the most matching haar value. When each stage is obtained more and more matching values, the category will decide that the object is recognized. If many haar values do not match the pixel character, they can be classified as unrecognized objects.
In that stage, all processes will be carried out to all positive images in the training folder. more input images, make the better the training result. All values that have been obtained in the previous process will then be stored as a dataset. Which will then be converted into a file with an XML extension. At this stage, the requirement to create a cascade dataset has been fulfilled. The process can be carried out by referring to the flowchart that has been shown previously. The following is a snippet of a successful cascade dataset creation. The result of this dataset is named dataset cascade.xml. As explained in the Figure 14.

Figure 13 Dataset Cascade Value
The image above is a snippet of the negative and positive image extraction results and has been converted into XML format. The existing cascade dataset cannot be implemented into the system to recognize objects before testing. If the test on the fake shallot object has been successfully recognized, the cascade dataset can be implemented. The following are the results of testing the cascade.xml dataset against mini onions or fake onions (Figure 15).

Figure 14 Cascade Result Testing
The display above is the result of testing the cascade.xml dataset against these onions or fake onions. The image used for testing is a photo image, not a video. With the cascade dataset that has been tested and declared to recognize the onion object, the next step is to create a new dataset containing the local binary pattern histogram (LBPH) value with the reference image. The reference image used is 50 images. The histogram values that have been extracted are then converted into an xml file with the name training.xml. The convertion results of dataset training can be seen in the Figure 16. After the training file exists, the next step is to implement the output stage. The previously created data cascade, namely cascade.xml and training.xml, will be used to perform the image reading process and calculate the match value based on the histogram value in the reference image with the histogram v alue input image. The following is the result of displaying the results of reading objects and labeling : Figure 16 System Testing From the picture above (Figure 17), it can be seen that the system has worked according to the previously mentioned design. In addition, the system also succeeded in detecting fake onion objects. Then the next step is to test and evaluate the performance of the system. The test was carried out by mixing mini onions with Brebes varieties of shallots. With the sampling method singly or in groups. The test was carried out between 2:00 PM -03:00 PM with a distance of 0-30 cm from the camera to the object. Below is an equation to calculate the percentage of system detection and an equation to calculate the average rate of the system.

CONCLUSION
From the research described above, it can be concluded that the Haar-Like Feature method can be applied as a method to recognize objects. Classification using the Haar-Like method consists of haar-like features, integral images, adaptive boosting, classifiers combined with local binary pattern histogram methods. The results of the feature extraction process from the input data are stored in the form of an XML file. The dataset needed in this method is the object feature dataset and the object histogram pattern dataset. The two datasets are run simultaneously, and after that, they are used to calculate object matches to the training data. The matched data is then used for the labeling process and percent calculation. Testing of objects does not have to be done singly but can also be done in groups as long as the onion's surface is visible and not covered by other objects. From the 30 objects test by testing objects individually or in groups, with a distance between the camera and objects of 15-30 cm, and the testing time between 13:00 -15:00, the results obtained were 69.2% of objects that were correctly recognized, and as many as six objects or 30.8%. The results of the system are influenced by several factors, including the object's position, the intensity of light, and the distance of the object to the camera. The recognition process with the optimum reading is that the farthest distance of the object is 15 cm and the lighting conditions around the object are bright.