Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void FindObject()
- {
- Logger.Instance.LogInfo("Aibo is at " + _vrAibo.Position + "with a rotation of " + _vrAibo.Rotation);
- int objectAheadThreshold = 0;
- System.Drawing.Point here = new System.Drawing.Point((int)_vrAibo.Position.Y, (int)_vrAibo.Position.X);
- Image<Gray, float> disp = new Image<Gray, float>(h, w);
- Image<Gray, byte> leftGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapLeftEye());
- Image<Gray, byte> rightGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapRightEye());
- doDispMap(ref disp);
- for (int a = 85; a < 170; a++)
- {
- for (int b = 85; b < 170; b++)
- {
- Gray pixel = disp[b, a];
- if (pixel.Intensity > 25)
- {
- objectAheadThreshold++;
- }
- }
- }
- Logger.Instance.LogInfo("ObjectThreshold: " + objectAheadThreshold);
- _frmDispMap.SetImage(disp);
- if (objectAheadThreshold > 0) State_AvoidRoundObject(objectAheadThreshold);//return true;
- //return false;
- }
- private void State_AvoidRoundObject(int threshold)
- //Weicht runden Objekten aus.
- //Findet Objekt, dreht sich ein Stück, prüft, ob Objekt immernoch in front.
- //Verbleibendes Problem: wie finde ich die Straße wieder?
- {
- Logger.Instance.LogInfo("Swich state to AVOID_ROUND_OBJECT " );
- int objectAheadThreshold = threshold;
- int turnedSoFar = 0;
- System.Drawing.Point here = new System.Drawing.Point((int)_vrAibo.Position.Y, (int)_vrAibo.Position.X);
- Image<Gray, float> disp = new Image<Gray, float>(h, w);
- Image<Gray, byte> leftGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapLeftEye());
- Image<Gray, byte> rightGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapRightEye());
- while(objectAheadThreshold > 0){
- doDispMap(ref disp);
- if (objectAheadThreshold > 500)
- {
- _vrAibo.Strafe(0.7f);
- _vrAibo.Turn(-3);
- turnedSoFar = turnedSoFar + 3;
- _frmDispMap.SetImage(disp);
- _vrAibo.Update();
- }
- if ( objectAheadThreshold < 500)
- {
- _vrAibo.Walk(0.7f);
- _vrAibo.Update();
- }
- objectAheadThreshold = 0;
- for (int a = 85; a < 170; a++)
- {
- for (int b = 85; b < 170; b++)
- {
- Gray pixel = disp[b, a];
- if (pixel.Intensity > 25)
- {
- objectAheadThreshold++;
- }
- }
- }
- // _vrAibo.Turn( turnedSoFar);
- Logger.Instance.LogInfo("ObjectThreshold: " + objectAheadThreshold);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement