Skip to content

Commit e9dcffe

Browse files
committed
increase buffer length
1 parent 2890800 commit e9dcffe

File tree

5 files changed

+48
-27
lines changed

5 files changed

+48
-27
lines changed

bloks/camera.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def continuous_capture():
3030
cap = cv2.VideoCapture(0) # Opens the USB camera stream
3131
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 3840) # Set the width of the frame
3232
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 2160) # Set the height of the frame
33-
cap.set(cv2.CAP_PROP_BUFFERSIZE, 2) # Set the buffer size to 1
33+
cap.set(cv2.CAP_PROP_BUFFERSIZE, 5) # Set the buffer size to 1
3434
cap.set(cv2.CAP_PROP_FPS, FPS) # Set frames per second
3535
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
3636

bloks/display.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def predict_and_show():
179179
combined_layers = cv2.putText(
180180
combined_layers,
181181
f"Bin #{next_bin[0]}",
182-
(20, (count*50)+50),
182+
(20, (count*60)+60),
183183
cv2.FONT_HERSHEY_DUPLEX, 2, (255, 0, 0), 5
184184
)
185185

@@ -195,7 +195,7 @@ def predict_and_show():
195195
combined_layers = cv2.putText(
196196
combined_layers,
197197
f"FPS: {session_stats.fps()}",
198-
(combined_layers.shape[1]-600, 100),
198+
(combined_layers.shape[1]-500, 100),
199199
cv2.FONT_HERSHEY_DUPLEX, 3, (255, 0, 0), 5
200200
)
201201

docs/installer.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
44

55
The installer runs through a serious of operations to install OpenBlok. The operations are listed below:
66

7-
1. Install Dependencies
7+
1. Verify the installer is running as root
8+
2. Verify the user "blok" exists
9+
3. Install Dependencies
810
- Python 3.10
911
- Package unzip
1012
- Package jq
13+
- Package v4l-utils (for audio generation)
1114
- cv2 required packages ffmpeg libsm6 libxext6
12-
2. Get OpenBlok
15+
4. Get OpenBlok
1316
- Get latest release version number
1417
- Download OpenBlok Zip from GitHub
1518
- unzip OpenBlok Zip
16-
3. Create Environment
19+
5. Create Environment
1720
- Create virtual environment
1821
- Install Python dependencies
19-
4. Create System Files
22+
6. Create System Files
2023
- /opt/OpenBlok/system.json
21-
5. Housekeeping
24+
7. Housekeeping
2225
- Remove temp zip file
2326
- Set permissions

install.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ Help()
2121
URL="blokbot.io"
2222
DEBUG=false
2323

24+
# -------------------------------- Verify Root ------------------------------- #
25+
if [ "$EUID" -ne 0 ]
26+
then echo "Please run as root with sudo."
27+
exit
28+
fi
29+
30+
# -------------------------------- Verify User ------------------------------- #
31+
if ! id blok &>/dev/null; then
32+
sudo adduser --disabled-password --gecos "" blok
33+
sudo usermod -aG sudo blok
34+
fi
35+
2436
# ---------------------------------------------------------------------------- #
2537
# Dependencies #
2638
# ---------------------------------------------------------------------------- #
@@ -55,6 +67,17 @@ else
5567
echo "jq already installed, skipping..."
5668
fi
5769

70+
71+
# --------------------------------- v4l-utils -------------------------------- #
72+
REQUIRED_PKG="v4l-utils"
73+
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
74+
if [ "" = "$PKG_OK" ]; then
75+
echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG..."
76+
sudo apt-get install v4l-utils -y
77+
else
78+
echo "v4l-utils already installed, skipping..."
79+
fi
80+
5881
# ---------------------------------- ffmpeg ---------------------------------- #
5982
REQUIRED_PKG="ffmpeg"
6083
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")

openblok.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
# ---------------------------------------------------------------------------- #
1616
# Flags and Variables #
1717
# ---------------------------------------------------------------------------- #
18-
# Degrees to rotate frame for alignment.
19-
config.rotational_offset = None
18+
config.rotational_offset = None # Degrees to rotate frame for alignment.
2019

21-
config.frame_queue = Queue(maxsize=3) # Queue of frames to be displayed.
22-
# Flag | None to request a frame, else contains the frame.
23-
config.requested_frame = None
20+
config.frame_queue = Queue(maxsize=10) # Queue of frames to be displayed.
21+
22+
config.requested_frame = None # Flag | None to request a frame, else contains the frame.
2423

2524
config.enable_sine_wave = False # TEMP TO TEST
2625

@@ -37,33 +36,29 @@
3736
config.y_bounding_offset = 2.250 # Configuration | Y Bounding Offset
3837
config.x_bounding_offset = 0 # Configuration | X Bounding Offset
3938

40-
check_results = []
41-
check_results.append(precheck.validate_requirements())
42-
# check_results.append(precheck.peripheral_check())
43-
44-
if False in check_results:
45-
print("OpenBlok cannot be run, please check the requirements and peripherals")
39+
if not precheck.validate_requirements():
40+
print("OpenBlok cannot be run, please check the requirements.")
4641
sys.exit()
4742

48-
# Update models
49-
updater.update_models()
43+
# if not precheck.peripheral_check():
44+
# print("OpenBlok cannot be run, please check the peripherals.")
45+
# sys.exit()
46+
47+
updater.update_models() # Update models
5048

5149
# ---------------------------------------------------------------------------- #
5250
# Start Threads #
5351
# ---------------------------------------------------------------------------- #
5452
# Camera Thread
55-
start_camera = threading.Thread(target=camera.continuous_capture)
56-
start_camera.start()
53+
threading.Thread(target=camera.continuous_capture).start()
5754
print("INFO | Camera thread started.")
5855

5956
# Start Serial Listener
60-
serial_listener = threading.Thread(target=serial.serial_listener)
61-
serial_listener.start()
57+
threading.Thread(target=serial.serial_listener).start()
6258
print("Serial listener thread started.")
6359

6460
# Start Carousel Position Thread
65-
carousel_position = threading.Thread(target=serial.carousel_position)
66-
carousel_position.start()
61+
threading.Thread(target=serial.carousel_position).start()
6762
print("INFO | Carousel position thread started.")
6863

6964
# Display Thread

0 commit comments

Comments
 (0)