Thomas Ashworth / theRobot

Dependencies:   Adafruit-16-Ch-PWM-Servo-Driver HCSR04 PID PololuQik2 QEI Sharp mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
tashworth
Date:
Wed Apr 02 04:04:28 2014 +0000
Parent:
14:784acd735b8c
Child:
16:8bb212df81b7
Commit message:
4-1-14 11pm

Changed in this revision

ShapeDetect.cpp Show annotated file Show diff for this revision Revisions of this file
ShapeDetect.h Show annotated file Show diff for this revision Revisions of this file
--- a/ShapeDetect.cpp	Wed Apr 02 03:36:49 2014 +0000
+++ b/ShapeDetect.cpp	Wed Apr 02 04:04:28 2014 +0000
@@ -329,3 +329,36 @@
     return s_area_val;
 }
     
+    
+int rigDetectionImgProc(void){
+    
+    ImageToArray(GREYSCALE);
+    int count1 = 0;
+    int count2 = 1;         
+        
+        //first rig       
+        for(int i=40; i<80; i++){
+                 for(int j=0; j<60; j++){
+                     if (image[i][j] < 128); 
+                     count1++;
+                    }// j
+                 }// i
+                 
+         //second rig        
+        for(int i=0; i<120; i++){
+                 for(int j=139; j<160; j++){
+                     if (image[i][j] < 128); 
+                     count2++;   
+                    }// j
+                 }// i
+                 
+        if( (count1 < RIG_IP_THRESHOLD)  && (count2 < RIG_IP_THRESHOLD) ){
+            //no fire detected on forst two rigs
+            return 3; // CIRCLE RIG
+            } else if(  count1 > RIG_1_IP_THRESHOLD ){
+                return 1; //SQUARE RIG
+                } else {
+                    return 2; //TRIANGLE RIG
+                    }
+    
+    }
--- a/ShapeDetect.h	Wed Apr 02 03:36:49 2014 +0000
+++ b/ShapeDetect.h	Wed Apr 02 04:04:28 2014 +0000
@@ -14,6 +14,8 @@
 #define GREYSCALE 2
 #define DECIMAL   3
 
+#define RIG_IP_THRESHOLD 1000
+#define RIG_1_IP_THRESHOLD 3000
 
  
 void lrf_baudCalibration(void);
@@ -24,6 +26,7 @@
 void clearBounds(void);
 int shapeDetection(void);
 int getDistance(void);
+int rigDetectionImgProc(void);
 
 int get_com_x(void);
 int get_com_y(void);