hanyazou / TelloPy

DJI Tello drone controller python package
Other
687 stars 292 forks source link

changing the directory for pictures and video #78

Open trooperisme opened 4 years ago

trooperisme commented 4 years ago

Hi, This is a very very easy easy question, but I dont know how to work with '%s'. Let's say that my directory is: C:\Users\hi\Pictures\fly

trooperisme commented 4 years ago

path = '%sUsers/hi/Pictures/Screenshots/tello-%s.jpeg' % ( 'C:/', datetime.datetime.now().strftime('%Y-%m-%d_%H%M%S')) with open(path, 'wb') as fd: fd.write(data) status_print('Saved photo to %s' % path)

I switch the os.getenv() method back to 'C:/'. Then I end up getting the message:

Tello: 13:25:14.920: Info: unknown packet: 0030 cc 60 00 27 b0 30 00 00 00 00 02 0d Tello: 13:25:14.921: Info: recv: file size: cc 90 00 be 88 62 00 2e 00 01 d8 d5 09 00 00 00 2b 5f Tello: 13:25:14.921: Info: file size: num=0 bytes=644568 ALT: 10 | SPD: 0 | BAT: 61 | WIFI: 90 | CAM: 0 | MODE: 6 Tello: 13:25:14.971: Info: recv: file size: cc 60 00 27 50 62 00 2e 00 00 db ff Tello: 13:25:14.972: Warn: file size: payload too small: 00.

Then the camera screen starts to freezing. I am so confused now, also I cannot record video either (mostly due to the 'path')

Thanks,

viet2411 commented 4 years ago

Hello, I also changed the os.getenv() method back to 'C:/', but I received the file not found error. Have you solved this problem yet?

trooperisme commented 4 years ago

Hi Viet, I tried but it still doesn’t work out. I have been playing around with the path but I cant figure it out (i am stupid lol). I think you should keep it as default !!!

viet2411 commented 4 years ago

Update: I switched the os.getenv() method to os.getcwd() and was able to capture a picture, but the camera screen freezed after that. Still don't understand why this happenned lol

trooperisme commented 4 years ago

Update: I switched the os.getenv() method to os.getcwd() and was able to capture a picture, but the camera screen freezed after that. Still don't understand why this happenned lol

that is exactly what I experienced (you still can have access to control via your device, it is just the camera doesn't get the images)

trooperisme commented 4 years ago

@hanyazou please help if you feel free

gemSquared commented 4 years ago

Hello! I just removed all the previous directory jazz and did "telloPic" + str(round(time.time())) + ".png" for the path. It'll save to the same folder as the python script.

trooperisme commented 4 years ago

oh thats nice, it makes more sense to me tho

viet2411 commented 4 years ago

Has anyone recorded the video yet?

Walt-H commented 4 years ago

@viet2411 I was able to do this through Windows :)

I had to do the following:

  1. Download Mplayer for Windows here: https://sourceforge.net/projects/mplayerwin/files/MPlayer-MEncoder/r38151/mplayer-svn-38151-x86_64.7z/download

  2. Unzip the file via 7zip

  3. Add the extracted folder to your PATH (I followed this guide)

    • I had to restart PyCharm after doing this, so restart your IDE to make sure it gets the new enviroment.
  4. Install the wheel (see README) and add the following packages into your Python environment via pip: av, opencv-python, image, pygame

  5. In keyboard_and_video.py, change the filename at line 57 to a Windows friendly directory

    • e.g. '%s\\Pictures\\tello-%s.mp4' % ('C:\\Users\\Buddy', datetime.datetime.now().strftime(date_fmt))
    • I would recommend doing this for jpegs at line 209
  6. Uncomment line 62 and 63 (may not be necessary, but I did it anyway)

  7. Run keyboard_and_video.py

  8. Hit R

  9. Fly Around a Little

  10. Hit R

  11. Land and gracefully terminate program

And now I have an MP4 that I have to open through Google Chrome to view :)

giphy

viet2411 commented 4 years ago

@Walt-H Finally I can record video with this program. Thank you so much for your support!