Compare commits

...

3 Commits

Author SHA1 Message Date
alban d0cef35096 [enh] Adds an opencv realtime video capture + point detection 2020-10-15 14:06:01 +02:00
alban a9268b0d73 [fix] install.sh typo was breaking the install 2020-10-14 18:12:35 +02:00
alban 98538662b8 [fix] The install should be more streamlined 2020-10-14 17:16:25 +02:00
2 changed files with 78 additions and 47 deletions

47
clitools/generators/opencv2.py Executable file
View File

@ -0,0 +1,47 @@
import cv2
import numpy as np
from PIL import Image
from numpy import asarray
import potrace
color = 65280
camera = cv2.VideoCapture(0)
camera.set(cv2.CAP_PROP_FRAME_WIDTH, 160)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 120)
camera.set(cv2.CAP_PROP_FPS, 5)
print("camera FPS:{} height:{} width:{}".format(camera.get(cv2.CAP_PROP_FPS), camera.get(cv2.CAP_PROP_FRAME_WIDTH), camera.get(cv2.CAP_PROP_FRAME_HEIGHT)))
while(camera.isOpened()):
pl = []
ret, frame = camera.read()
if ret==True:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.Canny(gray, 100,120 )
(thresh, gray) = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
nb = cv2.cvtColor(asarray(gray), cv2.COLOR_RGB2BGR)
image = Image.fromarray(nb).convert("1")
image.save( "/tmp/cv.png")
bmp = potrace.Bitmap( asarray( image ) )
# Trace the bitmap to a path
path= bmp.trace(turdsize=16,alphamax=0.0, opticurve=0, opttolerance=1.0)
# Iterate over path curves
for curve in path:
start = curve.start_point
pl.append([start[0],start[1],0])
pl.append([start[0],start[1],color])
for segment in curve:
end_point_x, end_point_y = segment.end_point
if segment.is_corner:
#c_x, c_y = segment.c
pass
else:
c1_x, c1_y = segment.c1
x, y = segment.c2
pl.append([x,y,color])
pl.append([start[0],start[1],0])
ret, frame = camera.read()
#print(len(pl), flush = True)
print(pl, flush = True)
else:
break
# Release everything if job is finished
camera.release()

View File

@ -1,48 +1,32 @@
#!/bin/bash
sudo apt upgrade
sudo apt install python3-pip
sudo apt install redis-server
# for dedicated computer after fresh linux install. todo : ask if needed.
#sudo apt install git
#sudo apt install syncthing
#sudo apt install htop
#sudo apt install screen
#sudo apt install tmux
#sudo apt install nginx
#sudo apt install supervisor
#sudo apt install ssh
# todo one day : modify correct path in syncthing.conf
#sudo cp syncthing.conf to /etc/supervisor/conf.d/
pip3 install scipy
pip3 install numpy
#pip install pygame==1.9.2
#pip3 install pygame==1.9.2
pip3 install redis
pip3 install pysimpledmx
pip3 install DMXEnttecPro
sudo apt install libasound2-dev
sudo apt install libjack-dev
pip3 install python-rtmidi
pip3 install mido
git clone https://github.com/ptone/pyosc --depth 1 /tmp/pyosc && cd /tmp/pyosc && sudo ./setup.py install
pip3 install tk
cd ../
python3 configure.py
# todo : ask for computer ip and run updateUI.py
cd /tmp
sudo apt install portaudio19-dev
sudo apt install cmake
git clone https://github.com/Ableton/link.git
cd link
git submodule update --init --recursive
mkdir build
cd build
cmake ..
cmake --build .
cd /tmp/
git clone --recursive https://github.com/gonzaloflirt/link-python.git
cd link-python
mkdir build
cd build
cmake ..
cmake --build .
# Check if root
[[ 0 -ne $UID ]] && { echo "Must run as root. Exiting."; exit; }
# Propose some packages
echo -e "\nThe following packages are not mandatory, add them as needed.\n"
declare -a ADD_PACK
POS_PACK=( htop nginx screen ssh ssl-cert supervisor syncthing tmux )
POS_PACK_LEN=${#POS_PACK[@]}
for i in ${!POS_PACK[@]} ; do
pack=${POS_PACK[i]}
read -e -n 1 -p "$((i+1))/${POS_PACK_LEN} Add package ${pack} ? [Y/n]: "
REPLY=${REPLY:-Y}
[[ "Y" == ${REPLY^^} ]] && ADD_PACK+=(${pack})
done
# Propose the install
PACK_LIST=$( echo "cmake git libasound2-dev libjack-dev libsdl1.2-dev network-manager portaudio19-dev python3-dev python3-pip python3-rtmidi redis-server ${ADD_PACK[@]}" | sort )
echo -e "\nYou are goind to install:\n$( for pack in ${PACK_LIST[@]}; do echo ' * '$pack; done; )\n"
read -e -n1 -p "OK? [Y/n]: "
REPLY=${REPLY:-Y}
[[ "N" == ${REPLY^^} ]] && exit
# Run the install
apt install -y --no-install-recommends $PACK_LIST
pip3 install setuptools
pip3 install DMXEnttecPro mido numpy pysimpledmx redis scipy
git clone https://github.com/ptone/pyosc --depth 1 /tmp/pyosc && cd /tmp/pyosc && ./setup.py install
cd /tmp && git clone https://github.com/Ableton/link.git && cd link && git submodule update --init --recursive && mkdir build && cd build && cmake .. && cmake --build .
cd /tmp/ && git clone --recursive https://github.com/gonzaloflirt/link-python.git && cd link-python && mkdir build && cd build && cmake .. && cmake --build .
cd /opt/ && git clone https://git.interhacker.space/teamlaser/LJ