Skip to content

Commit

Permalink
bug fixes, add convenience tools in deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
jehontan committed May 26, 2022
1 parent b58c838 commit 379534d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
__pycache__
*.egg-info/
*.egg-info/
build
36 changes: 36 additions & 0 deletions deploy/deploy_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps
./install_pivariety_pkgs.sh -p imx519_kernel_driver

sudo apt install -y python2
sudo apt install -y raspberrypi-kernel-headers
sudo apt install -y gstreamer1.0-tools
mkdir /home/pi/$(uname -r)

# download kernel source code
cd ~
sudo apt install git bc bison flex libssl-dev
sudo wget https://raw.githubusercontent.com/RPi-Distro/rpi-source/master/rpi-source -O /usr/local/bin/rpi-source && sudo chmod +x /usr/local/bin/rpi-source && /usr/local/bin/rpi-source -q --tag-update
rpi-source -d $(uname -r)

# compile driver
cd ~
git clone --branch v0.12.5 https://github.com/umlaeute/v4l2loopback.git
cd v4l2loopback
make clean && make
make && sudo make install
sudo depmod -a

# use v4l2loopback
sudo modprobe v4l2loopback video_nr=3
gst-launch-1.0 libcamerasrc ! 'video/x-raw,width=1920,height=1080' ! videoconvert ! tee ! v4l2sink device=/dev/video3

# install
sudo apt install python3-opencv
git clone https://github.com/jehontan/vision_localization.git
echo 'export PATH=$PATH:${HOME}/.local/bin' >> ~/.bashrc

# autofocus
libcamera-still -t 0 --keypress
9 changes: 9 additions & 0 deletions deploy/multiview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<body>
<img src='http://camera1.local:5127/preview' height=420px/>
<img src='http://camera2.local:5127/preview' height=420px/>
<br>
<img src='http://camera3.local:5127/preview' height=420px/>
<img src='http://camera4.local:5127/preview' height=420px/>
</body>
</html>
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="vision_localization",
version="0.0.1",
version="1.0.0",
author="Je Hon Tan",
author_email="[email protected]",
description="Vision-based localization using ArUco markers.",
Expand Down
2 changes: 1 addition & 1 deletion src/vision_localization/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def main():
np.savez(args.out_file,
allCharucoCorners=allCharucoCorners,
allCharucoIds=allCharucoIds,
img_size=img_size,
img_size=np.array(img_size, dtype=int),
board_cols=args.board_cols,
board_rows=args.board_rows,
chess_size=args.chess_size,
Expand Down
7 changes: 4 additions & 3 deletions src/vision_localization/offline_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ def main():

board = cv2.aruco.CharucoBoard_create(int(data['board_cols']), int(data['board_rows']), float(data['chess_size']), float(data['marker_size']), marker_dict)

repError, K, D, rvecs, tvecs = cv2.aruco.calibrateCameraCharuco(data['allCharucoCorners'],
data['allCharucoIds'],
repError, K, D, rvecs, tvecs = cv2.aruco.calibrateCameraCharuco(data['allCharucoCorners'].tolist(),
data['allCharucoIds'].tolist(),
board,
data['img_size'],
np.eye(3),
np.zeros((4,1)))
np.zeros((5,1)))

with open(args.out_file, 'w') as f:
f.write('repError: {}\n'.format(repError))
f.write('fx: {}\nfy: {}\ncx: {}\ncy: {}\n'.format(K[0,0], K[1,1], K[0,2], K[1,2]))
f.write('D: {}\n'.format(D.flatten().tolist()))

logging.info('Wrote calibration output to {}'.format(args.out_file))
logging.info('Done.')

if __name__ == '__main__':
main()

0 comments on commit 379534d

Please sign in to comment.