Hi everyone. I would like to do the bebop2 video streaming on ubuntu using opencv and python. I used the code below but unfortunately i was unable to get the streaming because of the "from pyparrot.Model import Model " problem. Anyone knows how to solve it? thanks.
from pyparrot.Bebop import Bebop
from pyparrot.DroneVision import DroneVision
from pyparrot.Model import Model
import threading
import cv2
import time
isAlive = False
class UserVision:
def init(self, vision):
self.index = 0
self.vision = vision
def save_pictures(self, args):
#print("saving picture")
img = self.vision.get_latest_valid_picture()
if (img is not None):
filename = "test_image_%06d.png" % self.index
#cv2.imwrite(filename, img)
self.index +=1
make my bebop object
bebop = Bebop()
connect to the bebop
success = bebop.connect(5)
if (success):
# start up the video
bebopVision = DroneVision(bebop, Model.BEBOP)
userVision = UserVision(bebopVision)
bebopVision.set_user_callback_function(userVision.save_pictures, user_callback_args=None)
success = bebopVision.open_video()
if (success):
print("Vision successfully started!")
#removed the user call to this function (it now happens in open_video())
#bebopVision.start_video_buffering()
# skipping actually flying for safety purposes indoors - if you want
# different pictures, move the bebop around by hand
print("Fly me around by hand!")
bebop.smart_sleep(5)
print("Moving the camera using velocity")
bebop.pan_tilt_camera_velocity(pan_velocity=0, tilt_velocity=-2, duration=4)
bebop.smart_sleep(25)
print("Finishing demo and stopping vision")
bebopVision.close_video()
# disconnect nicely so we don't need a reboot
bebop.disconnect()
else:
print(“Error connecting to bebop. Retry”)