Saturday, February 16, 2013

Magellan classes diagram and progress in camera module (Feb. 16)

          During winter 2013, progress was made to the Magellan platform in camera module. As it is shown in the diagram, camera module consists of three parts: contracking2 class, rr_api class and roborealm program.

          Originally, there are three main functions in contracking2 class: Initialize_Vision_API(), which initialize the camera and roborealm program, getCOG(), which returns the center of gravity of the target, and terminate_roborealm(), which close the camera and roborealm program. The original roborealm program was made to detect the red color and within a range of threshold and size, and return the center of gravity of the detected red area.

          In some degree, it was a powerful program to detect red cones. However, the program might lead Magellan to the wrong way when it detects other red object such as a red wall, red T-shirts that people wears or a bottle with red cover.

          As a result, the roborealm program was developed to detect the target according to not only colors but also shapes. In the developed roborealm program, “improve2.robo”, a module called shape match was used to detect the shape of targets.


          A folder of pictures can be loaded in this module, and it is used to compare the pictures in the folder and the detected image from camera. Once the program find a target matches the loaded pictures, it would use a green rectangle frame to surround the object and return a value called “confidence”.

          “Confidence” is a value that describes the similarity between the loaded pictures and the detected object. The higher confidence value returns, the more accurate the object matches.

          In the improved contracking2 class, a new function called getConfidence() was made to get this value to help to determine if the detected object is the target cone. Correspondly, a function called Check_Cone() was made in the test Magellan class to help to find the target cones:

def getCOG_shapeMatch( ):
        c_X = float(rr.GetVariable("SHAPE_X_COORD"))
        c_Y = float(rr.GetVariable("SHAPE_Y_COORD"))
        c_size = float(rr.GetVariable("SHAPE_SIZE"))
        c_X = 9999
        c_Y = 9999
        c_size = 0
    return [c_X, c_Y, c_size]

def getConfidence():
        confidence = float(rr.GetVariable("SHAPE_CONFIDENCE"))
        confidence = 999
    return confidence

getCOG_shapeMatch( ) and  getConfidence() functions were added to conetracking2 class to get the center of gravity, size and the confidence value from roborealm. Their test code was to identity the target cones, and return the center of gravity when the confidence is more than 80:

if __name__=="__main__":
    c = getConfidence()
    while c< 80 or c>100:
        c = getConfidence()
        if c>80 and c< 100:
            print "target found"
            print getCOG( )

The two functions below were made in Magellanclass module to identity cones from other objects by continually getting confidence value from roborealm. The function Confidence_Filter() could increase the accuracy of cone searching.

 def Confidence_Filter():
        coneFound = False
        for i in range(10):
            c = getConfidence()
            if(c>80 and c<100):
                coneFound = True
        return coneFound           
  def Check_Cone():
        [cone_X,cone_Y,cone_size] = getCOG()
        cf = False
        if ((cone_X!=9999) and Confidence_Filter()):
            cf = True
        return cf

          Also, a module in roborealm called “mean filter” is used to better detect the objects in a further distance or in dark light.

before mean filter

after mean filter

          Finally, pictures of cones are used to match the detected objects, and red objects with different shape such as a bottle of red cover and an orange drill were used to test the program. It returned a very high confidence value, more than 80, to detect the cone from other shapes; It showed a very good performance to find the cone within 3-4 meters.


(more upgraded functions and classes for camera module: 
Dropbox\Robotics Team\Engr 99 Robotics\Magellan-James\test)

No comments:

Post a Comment