Setup Pi/Record Video

program that can find patterns or make decisions from a previously unseen dataset.

1 - Record video

import picamera
from time import sleep
from subprocess import call

with picamera.PiCamera() as camera:
    camera.start_recording("pythonVideo.h264")
    sleep(5)
    camera.stop_recording()

# The camera is now closed.
command = "MP4Box -add pythonVideo.h264 convertedVideo.mp4"
call([command], shell=True)
print("Video converted.")

#src: https://www.youtube.com/watch?v=TeMX9MjrJLY&t=555s

or

from picamera2 import Picamera2, Preview
picam2 Picamera2()
picam2.start_and_record_video("test.mp4", duration = 60, show_preview = True)

# src: https://www.youtube.com/watch?v=TeMX9MjrJLY&t=555s

2 - ArduPilot

Installation Instructions [1]

Open the terminal with Ctrl + Alt + T

sudo apt-get update
sudo apt-get install git
sudo apt-get install gitk git-gui
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git

Note: this takes a minute

cd ardupilot
Tools/environment_install/install-prereqs-ubuntu.sh -y

Note: this takes a minute

. ~/.profile

3 - Dronekit

Open the terminal with Ctrl + Alt + T

cd ~
git clone https://github.com/dronekit/dronekit-python
cd dronekit-python

sudo python setup.py install

Dronekit Simple_goto example

cd examples/simple_goto
gedit modified_goto.py

Location Changes

Mojave=35.059217, -118.150861,0.0,0
Mojave_1=35.063570, -118.156204,0.0,0
Mojave_2=35.059257, -118.157724,0.0,0
## open new terminal
cd ardupilot/Tools/autotest

nano locations.txt

## add the followig: 
Mojave=35.059217, -118.150861,0.0,0

4 - Set up Pi - Installation

Python Library Versions located here

Ctrl + Alt + T

NOTE: (2:54)

-click top left

-preferences

-raspberry pi configuration

-tabs: interfaces

-enable camera

-reboot

5 - Run Yolov5

Ctrl + Alt + T

Download your best.pt file after training, you can use Github or Google Drive

cd yolov5

cp ~/Downloads/best.pt .

gedit detect.py

  • (Note: make sure you use correct naming convention)

  • got to line 53 and type:

    • weights = 'best.pt',

  • go and comment line 54:

    • weights = 'yolov5s.pt',

sudo python3 detect.py

sudo python3 detect.py --weights 3-27-13-best.pt --source 0 or sudo python3 detect.py --weights best.pt --source 0

6 - config

ssh pi@195.168.43.153
sudo apt-get update && upgrade
sudo pip install pymavlink mavproxy

sudo raspi-config > serial activate > restart

nano /boot/config.txt
ls /dev/tty*
# Look for AMA0

sudo -s
mavproxy.py --master=/dev/ttyAMA0 --baudrate 921600 --aircraft MyCopter

# src - https://www.youtube.com/watch?v=BSDST7ePOtM

Last updated