Beispiel #1
0
def avoidGreen(frame, fromX, toX, fromY, toY, limit):
    "numpy implementation"
    return cimg.avoidGreen(frame, fromX, toX, fromY, toY, limit, 1.1)


def stripLeftRight(frame, fromY, toY, limit):
    width = frame.shape[1]
    xL = avoidGreen(frame, width / 2, 0, fromY, toY, limit=limit)
    xR = avoidGreen(frame, width / 2, width, fromY, toY, limit=limit)
    return xL, xR


def processAvoidGreen(frame, debug=False):
    height, width, colors = frame.shape
    offset = 0
    stripWidth = 70
    limit = 120
    topLR = stripLeftRight(frame, offset, offset + stripWidth, limit=limit)
    bottomLR = stripLeftRight(frame,
                              height - offset - stripWidth,
                              height - offset,
                              limit=limit)
    if debug:
        cv2.imshow('image', frame)
        saveIndexedImage(frame)
    return topLR, bottomLR


if __name__ == "__main__":
    imgmain(sys.argv, processAvoidGreen)  #processGreen )
Beispiel #2
0
    if count > limit:
      break
  return x

def avoidGreen( frame, fromX, toX, fromY, toY, limit ):
  "numpy implementation"
  return cimg.avoidGreen( frame, fromX, toX, fromY, toY, limit, 1.1 )

def stripLeftRight( frame, fromY, toY, limit ):
  width = frame.shape[1]
  xL = avoidGreen( frame, width/2, 0, fromY, toY, limit=limit )
  xR = avoidGreen( frame, width/2, width, fromY, toY, limit=limit )
  return xL,xR


def processAvoidGreen( frame, debug=False ):
  height, width, colors = frame.shape
  offset = 0
  stripWidth = 70
  limit = 120
  topLR = stripLeftRight( frame, offset, offset+stripWidth, limit=limit )
  bottomLR = stripLeftRight( frame, height-offset-stripWidth, height-offset, limit=limit )
  if debug:
    cv2.imshow('image', frame)
    saveIndexedImage( frame )
  return topLR, bottomLR

if __name__ == "__main__":
  imgmain( sys.argv, processAvoidGreen ) #processGreen )
 
Beispiel #3
0
                maxVideoDelay = max( videoDelay, maxVideoDelay )
                toDel = 0
                for oldTime, oldPose, oldAngles, oldAltitude in poseHistory:
                    toDel += 1
                    if oldTime >= videoTime:
                        break
                poseHistory = poseHistory[:toDel]
                
                print "FRAME", frameNumber/15
#                TODO

    except ManualControlException, e:
        print "ManualControlException"
        if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion
            drone.hover(0.1)
    drone.land()
    drone.wait(1.0)
    drone.stopVideo()
    print "MaxVideoDelay", maxVideoDelay
    print "MaxControlGap", maxControlGap
    print "Battery", drone.battery


if __name__ == "__main__":
    if len(sys.argv) > 2 and sys.argv[1] == "img":
        imgmain( sys.argv[1:], processFrame )
        sys.exit( 0 )
    import launcher
    launcher.launch( sys.argv, FreTask4Drone, freTask4 )
     
Beispiel #4
0
            #      print "%0.2f\t%d\t%0.2f\t%0.2f\t%0.2f" % (errY, int(math.degrees(errA)), drone.vy, sy, sa)
            prevTime = drone.time
            drone.moveXYZA(sx, sy, sz, sa)
            maxControlGap = max(drone.time - prevTime, maxControlGap)
            poseHistory.append(
                (drone.time, (drone.coord[0], drone.coord[1], drone.heading),
                 (drone.angleFB, drone.angleLR), altitude))
        print "NAVI-OFF", drone.time - startTime
        drone.hover(0.5)
        drone.land()
        drone.setVideoChannel(front=True)
    except ManualControlException, e:
        print "ManualControlException"
        if drone.ctrlState == 3:  # CTRL_FLYING=3 ... i.e. stop the current motion
            drone.hover(0.1)
        drone.land()
    drone.wait(1.0)
    drone.stopVideo()
    print "MaxVideoDelay", maxVideoDelay
    print "MaxControlGap", maxControlGap
    print "Battery", drone.battery


if __name__ == "__main__":
    if len(sys.argv) > 2 and sys.argv[1] == "img":
        imgmain(sys.argv[1:], processFrame)
        sys.exit(0)
    import launcher
    launcher.launch(sys.argv, RobotemRovneDrone, competeRobotemRovne)