This is a server module aimed to run the AlliedVision camera with the Thorlabs FilterWheel to collect a MultiSpectral dataset. The server is run on the RaspberryPi4 and controlled via a browser connected to the same network.
This module was tested on Ubuntu 20.04 (PC) and on a RaspberryPi 4 running Raspberry Pi OS 32bit.
RaspberryPi 3 wouldn't work because it lacks USB3 sockets.
The computer Must have USB-3 socket to connect the camera, and only using a USB-3 cable.
The server is run using python 3.7 with requirements detailed in requirements.txt.
For some reason, the automatic time syncronization (NTP) does not work on the RPI.
Every time apt-get
is used, the time and date should be manually set.
- Open the terminal (CTRL+T)
sudo sh
and the admin password (12345678)timedatectl set-time 2019-08-10
timedatectl set-time 21:45:53
- Add a file name
ssh
to the *boot partition of the Pi. - The default hostname and password are pi and raspberry respectively.
- Log into the Pi via ssh by typing
ssh [email protected]
- Change the relevant options by typing
sudo raspi-config
. - Change the password to
12345678
(one to eight). - Under Network Options (2.) change Hostname to
multispectralpi
. - Go to the options menu again, and enable VNC under Interface options.
- Change the default resolution under Advanced options. It doesn't really matter what resolution is set, as long as not the default one.
- Go back to the terminal.
- Type
sudo vncpasswd -service
- Add the following lines to /root/.vnc/config.d/vncserver-x11:
SecurityTypes=VncAuth
UserPasswdVerifier=VncAuth
- Start vncserver by typing
sudo vncserver-x11-serviced
- Set the correct time:
sudo date --set '2016-04-26 18:26:00
- Reboot using
sudo reboot
- Notice that to connect you need to type
ssh [email protected]
- Clone/Copy the Multispectral project.
- In the terminal run
sudo apt-get install libatlas-base-dev
- In the project folder, make
venv
and enter into it. - Setup a venv inside
/venv
:python3 -m venv .
- Activate it by
source bin/activate
- Make a file in
pi/home/
calledrun.sh
containing:
#! /bin/bash
source /path/to/multispectral/venv/bin/activate
cd /path/to/main
git reset --hard HEAD
git pull
python3 main.py
- Make a new file on the desktop named
Multispectral.desktop
containing:
[Desktop Entry]
Terminal=true
Type=Application
X-KeepTerminal=true
StartupNotify=true
Exec=sudo /home/pi/run.sh
- Activate the venv by
source path/to/venv/bin/activate
- Install the requirements file using:
pip install -r requirements.txt
- Make sure to install on pip3 also.
- In the terminal run
sudo apt-get install libatlas-base-dev
- Install the Vimba software package from the AlliedVision site. The relevant version for the RaspberriPi4 is ARM.
- An installation guide is available under utils directory.
- After running
[InstallDir]/Vimba_x_x/VimbaUSBTL
, go toVimbaPython/Source
. - In
VimbaPython/Source
, using the pip in the environment you use runpip install .
.
- Follow the link: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md
- Access the server by the address
192.168.4.1:8000
sudo apt-get install xterm
mkdir -p ~/.config/autostart
- Open a terminal and type
cv ~/.config/autostart
- Ope a text editor and a new file
nano autostart-server.desktop
- Inside the file write and Be sure to change the paths of the files:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Exec=/usr/bin/lxterm -e '/path/to/run.sh | less'
Change DEFAULT_FILTER_NAMES_DICT in devices/FilterWheel/__init.py
.
- Type in the terminal
ssh [email protected]
to connect to the Pi via SSH. - The password should be set to
12345678
- Type
ifconfig
- Connect to the network "MultiSpectralPi". When connecting from a desktop, use a wifi dongle.
- Manually change the IP settings from DHCP to manual
- Check IPv4, and fill in the following fields:
- IP address: 192.168.4.? , where ? stands for an arbitrary integer (e.g 192.168.4.3)
- Subnet prefix length: 24
- Gateway: 192.168.4.1
- Save changes
- Disconnect and re-connect to the network to apply the changes
- Open terminal (in windows, either PowerShell or WSL), and type "ssh [email protected]"
- Enter Password (1-8)
- Connect the FilterWheel to the USB and to the electrical socket. Turn it on.
- Connect the AlliedVision camera to the USB-3 socket using a USB-3 cable.
- Connect any other relevant camera to the USB.
- Make sure the RaspberryPi and the client device (smartphone/computer) are connected to the SAME NETWORK.
- Run
python3 main.py
on the RaspberryPi with the venv (see above). - On the Client Device: open the web browser and enter:
multispectral.local:8000
- Follow the instructions on the screen to take a picture.
- To Download the image into the client device, press the link with the name of the image on the bottom of the web page.
- After each photograph, the results will be displayed on the bottom of the page.
- A previously captured photo can be uploaded and display using Upload a Photo button.
Two files are saved every time Take a Photo button is pressed:
The dimensions of the numpy file are:
(Filters, Number of samples, H, W)
- The filters are set by Set number of filters to be photographed, and by the filter names.
- The number of samples are set in the box Number of images in each filter.
- H, W are set by the camera.
Containing the filter name and the camera temperature during the captures.
The position in the CSV file corresponds to the channel number on the numpy file.
For example, if the fourth (4) line in the CSV is filter 11000, than numpy file [3, :, :, :] contains this filter.
cnt<counter>_yyyymmdd_h<hh>m<mm>s<ss>
with 'npy' and 'csv' suffix.
The counter is incremented automatically with each saved image.
- change camera port from usb2->usb3