Synerflight

## Motion Target Tracking with OpenCV and Character Serial Output to control Arduino

A motion object tracking application created using OpenCV. After running the application, select the object you want to track.

Python-install-requirements.bat

	Installs Python enviroment

SynerCV-install-requirements.bat

	Install CV requirment

Center-CV-Arduino.bat

	1. 	ROI your target on start 
	2. 	To create new track, Keep target on Center of the 			screen and Press E  
	3.	Press ENTER to Track

ROI-CV-Arduino.bat

	1. 	ROI Box on your target on start
	2.	To create new track, Press E  
	3.	ROI Box your target 
	4. 	then Press ENTER to Track

CV-Default.bat

	This operates without serial Arduino connection

	1. 	ROI Box on your target on start
	2.	To create new track, Press E  
	3.	ROI Box your target 
	4. 	then Press ENTER to Track

Change source video

	Center-CV-Arduino.py
	ROI-CV-Arduino.py
	CV-Default.py

uncomment the script as needed

#=======Video source========#

#video = cv2.VideoCapture(http://IP-URL:81/stream?URL)#IPCam  
#video = cv2.VideoCapture('video.mp4')#use Video.mp4 
#video = cv2.VideoCapture(0) # for using CAMERA

datas Folder

	1. COM.TXT - Comport serial number same as your connected 	device see: Windows Device Manager > PORTS

	2. BAUD.TXT  - Baud rate of your Serial device . default 	115200 for bluetooth or direct USB to Arduino

	3. IPT.TXT  - Contains Object screen positions Trigger 	points
	this is a targeting Treshold on where the object is 	located on the screen  think of it as a imaginary grid of 	trigger points

	X Axis "L" if 1IPT < (LF) Left filter

	X Axis "C" if threshold_distance this null point can be 	adjusted Center size filter

	X Axis "R" if 1IPT > (RF) Right filter

	Y Axis "U" if 2IPT < (DF) Down filter

	Y Axis "C" if threshold_distance this null point can be 	adjusted Center size filter

	Y Axis "D" if 2IPT > (UF) Up filter



Instruction  

      Ensure Baud Rate and Com Matches your bluetooth or USB connection from Datas folder
      Select Source of video
      Draw ROI box on first activation of the program
      and press Enter

 
 
Setup some Dependacy and Libraries 

   Required opencv-contrib-python 4.11.0.86
   open your open RUN and type CMD
   type this
   pip install opencv-contrib-python
   or for update to older versions
   pip uninstall opencv-contrib-python opencv-python opencv-   contrib-python-headless && pip install opencv-contrib-python


USE ARDUINO CV Sample which an Arduino Companion board translate the Raw serial input into PWM output for the Flight controller to read

## Key Command

Q = Quit
E = Retarget
P = Pause CV Tracking
O = UnPause CV Tracking

Numpad = Directions

8 = Forward
6 = Right
4 = Left
2 = Back


##Pins Assignment Synerduino Rover 

Sample uses Bi-Directional ESC

D2 = Servo 1 = Right motor
D6 = Servo 2 = Left Motor
D9 = Trigger Ultrasonic
D10 = Echo Ultrasonic

Uart 0 = Bluetooth/Serial Radio
