Evaluation of the color-based image segmentation capabilities of a compact mobile robot agent based on Google Android Smartphone

. This paper presents the evaluation of the image segmentation capabilities of a mobile robot agent based on a Google Android Smartphone. The mobile agent was designed to operate autonomously in an environment inspired in a soccer game. The pixel-based color image segmentation capabilities was performed by testing different two-dimensional look up tables created from two-dimensional color histograms of the objects appearing in the scenario. The best segmentation alternative was obtained when using of a two-dimensional look up table based on the H (hue) and V (value) color image description. The final conclusion is that a Google Android Smartphone has enough potential to define an autonomous mobile robot agent and play a game that requires color-based image segmentation capabilities.


Introduction
The development of a mobile robot ready to play a game is an application that requires the application of challenging technologies. The main goal of this work is the evaluation of the color-based image segmentation capabilities of a compact mobile robot based on Google Android Smartphone. The application scenario is inspired in the common game called soccer (in USA), football (in Europe), or futbol (in Spanish). This paper proposes the development of a comparative study on fast color-based image segmentation performed in a Google Android Smartphone. This paper has been developed in the direction of the creation of a full autonomous mobile robot agent based on this platform and with different potential game capabilities. In this paper, the mobile robot has to operate in a predefined scenario with the following color-based objects ( Figure 1): floor, in green color; the field line limits, in white color; the ball, in a yellow main color; the goals, in red (red team) and blue (blue team) colors; and the mobile robots, also in red and blue colors. The main hypothesis is that current Smartphones have enough capabilities to perform fast color-based image segmentation and autonomously control the evolutions of a game oriented mobile robot.

Background
The Android operating system is based on the Linux core and was developed by the Open Handset Alliance, led by Google. The creation of applications for Android based Smartphones and Tablets can be performed with the free Android SDK [1] that is based on the high level Java language with other specialized functions optimized for the specific hardware written in C. The main difference with the standard Java programming style is the use of events instead of a classic main function. The Integrated Development Environment (IDE) used in this work was the Eclipse 3.7.1 Indigo [2], the most popular IDE for Android which also includes the Java developer package.

Soccer mobile robots
The Robocup [3] domain and their leagues are the most popular reference for mobile robots which are designed to play a team game. This game domain define robots sizes and designs and up to 8 colors to define objects. Also it has different leagues; some of them are Small Size league, Medium Size league and Humanoid league. Nevertheless, the fulfillment of the rules defined by the Robocup domain is not the main goal of this work. Instead, we have defined a simplified game environment ( Figure 1) containing one ball, two robots and two goals.

Fast color-based image segmentation
The image segmentation techniques applied in this paper are inspired in [4] which proposed an optimized threshold algorithm applied to the YUV color space to perform image segmentation and object color classification with a limited hardware; and in [5] and [6] which proposed the use of a YUV/RGB LUTs or other derived color spaces for color indexing based on specific calibration techniques to improve color segmentation and avoid the problems caused by lightning conditions. In this direction, this paper proposes the use of a twodimensional LUT to define a fast segmentation methodology in order to take advantage of the limited number of colors defined in the proposed game. Figure 1 shows an image of the mobile robot implementation based on a Google Android Smartphone. The mobile robot is a cylindrical box that supports the Smartphone and an additional battery and also contains the wheels, DC motors, and one electronic board to control the motors. The rear camera of the Smartphone is used to obtain images of the soccer playfield in low resolution (320x240 pixels) and high color quality. In this mobile robot the Smartphone analyzes the images acquired and sends basic commands: forward, back, turn left, turn right to the electronic board to drive the evolutions of the DC motors of the mobile robot. The additional battery is used to power directly the DC motors, the electronic board, and the Smartphone trough the USB connection. Then, the Smartphone can operate even when the external battery of the mobile robot is fully discharged, for example, to send a message to request a battery change.

Mobile robot implementation
The Smartphone used in this proposal is the HTC Sensation powered by a dualcore 1.2 GHz processor, 768 MB of RAM memory, and Android 4.0.3. The Smartphone has several embedded sensors: GPS, ambient light sensor, digital compass, three-axial accelerometer, gyroscope, multi-touch capacitive touch screen, proximity sensor, microphone, and a frontal and a rear camera. An important feature of one Smartphone is its high resolution screen that will be very useful to show some real-time information of mobile robot internal operation. The Smartphone device runs an agent APP which includes three basic capabilities: the main functional threads, the graphical interface, and the sensor managers. There are many specific threads defined, one thread has to receive the camera images and implement different color-based segmentation functions, two threads sends and receives high-level movement orders with the electronic board that control the motors of the mobile robot. The definition of different threads in Android requires the initialization of an instance of extended thread class and override the run() function which contains the code that the thread will execute. Normally this function contains the main code with the computational load of the application.

Image processing implementation
Once the camera of the Smartphone is initialized a preview callback function is called each time that a new image is generated. This function is uses to implement the color-based image segmentation capabilities of the mobile robot agent. Figure  2 shows the execution timeline required by the preview callback function to process the current image. The blue line in the figure shows an irregular behavior for the frame processing time. This effect is caused by the internal implementation of the Android camera functions and probably by other background applications running simultaneously in the Smartphone. After a careful analysis, the cause of the problem was identified as the Android's garbage collector module that operates very frequently to dynamically allocate different memory requested.
This problem can be solved on Android version 2.2 (or later) by using a new callback implementation setPreviewCallbackWithBuffer that avoids memory demands for each frame using the same static buffer to allocate image data, and thus, preventing frequent calling to the garbage collector (see Fig. 2 red line).

Influence of the image color space
The development of this work requires the use of different color spaces to evaluate with one has the best segmentation performances when applying a two dimensional LUT to classify the colors of the images. Figure 3 shows the histograms of the time lapse between consecutive calls to the preview callback function (with static buffer) for different color spaces. The red histogram shows the time lapse values when applying a LUT by using the original YUV color space image. This process is performed in most of the cases by spending 30 ms. The green histogram shows the time lapse spend when converting the original YUV (equivalent to YCbCr) color image into the RGB color space and then applying a LUT to classify the pixels of the image. This process is performed in most of the cases by spending 40 ms. Finally, the blue histograms showing the callback processing time when converting the original YUV image into the HSV color space and then apply a LUT to individually classify the pixels of the images. This process is performed in most of the cases by spending 67 ms. These poor results are caused by the difficult conversion between of the YUV and HSV image color spaces using high level procedures.

Fast image segmentation
The proposed methodology to perform fast image segmentation is the definition of a LUT for each specific color space used. In this analysis, the LUTs are computed off-line and the evaluation of the classification performances requires the development of the following steps: 1) acquire several images of the game playfield with the rear camera of the Smartphone, 2) manually label the different elements and objects of the images, 3) compute a two-dimensional histogram of all pixels of the same color, and 4) combine the histograms of the different objects in a two-dimensional LUT. Figure 4 also shows three examples of two-dimensional histograms corresponding to the ball and to blue and red color. These histograms have been computed by using the RG color spaces with 256 bins in each axis. These histograms can be joined in a unique LUT according the different pertinence probabilities of each object.  Table 1 shows the results of a complete analysis performed to evaluate different color space combinations in the definition of a two-dimensional LUT optimized for the high quality images obtained with the Smartphone. The number of bins was limited to 32 after a trial and error test to simplify the final implementation in the Smartphone. The relative error shown in Table I is computed as the difference between a manually labeled image and the same image automatically classified with the LUT which was automatically obtained from the selected pixels of different images. The results in the column labeled as H have been obtained by creating the LUT from the conventional histograms and the results in the columns labeled as Ĥ have been obtained after convolving the histogram with a disk of 2 pixels radius (to expand the color-space area covered by each object in the histogram).
The analysis performed in this work has been developed by considering all combinations between the color spaces RGB, Gray, HSV, and YUV (labeled as Y-Cb-Cr). Additionally, the areas outside the game playfield field have been discarded and not compared. Figure 5-a shows the best LUT automatically obtained in this experiment, corresponding to the HV color spaces (case: histogram not convolved), and figure 5-b shows the image classification results obtained with this LUT. The average segmentation error obtained after comparing pixel by pixel the manual and automatic classification performed was 0.87%. The next best alternatives were based on the use of the HY, and the HG color spaces. Probably these results are strongly correlated with the high quality of the image acquired with the camera and all auto-adjusted photo-image features included in the Smartphone. The LUT shown in figure 5-a is very small (32x32 bins) and can be easily incorporated into the application of the Smartphone.   Figure 5-b also shows that there is an empty area in the LUT (0.7<H<0.95) that can be used, if required, to define a new color-based object (this area corresponds to the violet or purple color). Additionally, the results of figure 5-a also suggest that the basic classification information of the LUT could be expressed directly as different interval rules (as proposed in [4]) but it must be noticed that this alternative color classification will have always lower time-classification performances than the use of a LUT.

Conclusion
This paper presents the evaluation of the image segmentation capabilities of a compact mobile robot based on Google Android Smartphone. This proposal of a mobile robot takes advantage of the quality of the images provided by such devices. The time required to apply an image processing algorithm to the image acquired by the Smartphone has been analyzed and the effect of using a buffer in the preview callback function has been evaluated. Results show that the original YUV image can be classified in 30 ms whereas the converted RGB and HSV images in 40 and 67 ms respectively.
The best classification LUT was obtained from the two dimensional histograms of the H and V color spaces with an average error in the classification of the pixels of only 0.87%. The objection of using the HSV color space is that the conversion of the original images in the YUV color space to the HSV color space doubles the time required to classify an image. The time results obtained must depend largely on the Smartphone used but the time ratio is expected to be similar.
Future work will be focused in image calibration, algorithm optimization, and in additional image analysis procedures designed to estimate the relative distance to the different objects located in the playfield. Then the next efforts will be focused in the definition of the basic operational agent required to convert a Google Android Smartphone into a gaming mobile robot.