Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. public void FindObject()
  2. {
  3. Logger.Instance.LogInfo("Aibo is at " + _vrAibo.Position + "with a rotation of " + _vrAibo.Rotation);
  4. int objectAheadThreshold = 0;
  5. System.Drawing.Point here = new System.Drawing.Point((int)_vrAibo.Position.Y, (int)_vrAibo.Position.X);
  6. Image<Gray, float> disp = new Image<Gray, float>(h, w);
  7. Image<Gray, byte> leftGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapLeftEye());
  8. Image<Gray, byte> rightGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapRightEye());
  9. doDispMap(ref disp);
  10. for (int a = 85; a < 170; a++)
  11. {
  12.  
  13. for (int b = 85; b < 170; b++)
  14. {
  15. Gray pixel = disp[b, a];
  16. if (pixel.Intensity > 25)
  17. {
  18. objectAheadThreshold++;
  19.  
  20. }
  21. }
  22. }
  23. Logger.Instance.LogInfo("ObjectThreshold: " + objectAheadThreshold);
  24. _frmDispMap.SetImage(disp);
  25. if (objectAheadThreshold > 0) State_AvoidRoundObject(objectAheadThreshold);//return true;
  26. //return false;
  27. }
  28.  
  29. private void State_AvoidRoundObject(int threshold)
  30. //Weicht runden Objekten aus.
  31. //Findet Objekt, dreht sich ein Stück, prüft, ob Objekt immernoch in front.
  32. //Verbleibendes Problem: wie finde ich die Straße wieder?
  33. {
  34. Logger.Instance.LogInfo("Swich state to AVOID_ROUND_OBJECT " );
  35. int objectAheadThreshold = threshold;
  36. int turnedSoFar = 0;
  37. System.Drawing.Point here = new System.Drawing.Point((int)_vrAibo.Position.Y, (int)_vrAibo.Position.X);
  38. Image<Gray, float> disp = new Image<Gray, float>(h, w);
  39. Image<Gray, byte> leftGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapLeftEye());
  40. Image<Gray, byte> rightGrey = new Image<Gray, byte>((Bitmap)_vrAibo.GetBitmapRightEye());
  41. while(objectAheadThreshold > 0){
  42. doDispMap(ref disp);
  43. if (objectAheadThreshold > 500)
  44. {
  45. _vrAibo.Strafe(0.7f);
  46. _vrAibo.Turn(-3);
  47. turnedSoFar = turnedSoFar + 3;
  48. _frmDispMap.SetImage(disp);
  49. _vrAibo.Update();
  50. }
  51. if ( objectAheadThreshold < 500)
  52. {
  53. _vrAibo.Walk(0.7f);
  54. _vrAibo.Update();
  55. }
  56.  
  57. objectAheadThreshold = 0;
  58. for (int a = 85; a < 170; a++)
  59. {
  60.  
  61. for (int b = 85; b < 170; b++)
  62. {
  63. Gray pixel = disp[b, a];
  64. if (pixel.Intensity > 25)
  65. {
  66. objectAheadThreshold++;
  67. }
  68. }
  69.  
  70. }
  71. // _vrAibo.Turn( turnedSoFar);
  72. Logger.Instance.LogInfo("ObjectThreshold: " + objectAheadThreshold);
  73.  
  74.  
  75. }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement