<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Asky Q&amp;A - Recent questions and answers in AI + Rasberry PI</title>
<link>https://asky.uk/qa/ai-rasberry-pi</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: Multi-Zone Traffic Analytics (Multiple Lines + Directions) on Raspberry Pi</title>
<link>https://asky.uk/111/multi-traffic-analytics-multiple-lines-directions-raspberry?show=112#a112</link>
<description>How much RAM need it?</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/111/multi-traffic-analytics-multiple-lines-directions-raspberry?show=112#a112</guid>
<pubDate>Wed, 07 Jan 2026 22:35:18 +0000</pubDate>
</item>
<item>
<title>Simple AI Traffic Analytics (Object Count + Speed) on Raspberry P</title>
<link>https://asky.uk/110/simple-ai-traffic-analytics-object-count-speed-on-raspberry</link>
<description>Hardware: Raspberry Pi 4 / Raspberry Pi 5&lt;br /&gt;
AI type: Computer Vision – Traffic Analytics&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
This project combines AI-based object counting and speed estimation to build&lt;br /&gt;
a simple traffic analytics system on Raspberry Pi.&lt;br /&gt;
&lt;br /&gt;
The system detects vehicles, counts them, and estimates their speed using&lt;br /&gt;
camera input and lightweight AI models. Everything runs locally without&lt;br /&gt;
cloud services or GPUs.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
What you build&lt;br /&gt;
&lt;br /&gt;
- Vehicle detection using AI&lt;br /&gt;
- Real-time vehicle counting&lt;br /&gt;
- Approximate speed estimation&lt;br /&gt;
- Fully offline traffic analytics&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Required hardware&lt;br /&gt;
&lt;br /&gt;
- Raspberry Pi 4 or Raspberry Pi 5&lt;br /&gt;
- Camera (USB or Raspberry Pi Camera)&lt;br /&gt;
- microSD card&lt;br /&gt;
- Power supply&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Software requirements&lt;br /&gt;
&lt;br /&gt;
- Raspberry Pi OS&lt;br /&gt;
- Python 3&lt;br /&gt;
- OpenCV&lt;br /&gt;
- Ultralytics YOLO (lightweight model)&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
System architecture&lt;br /&gt;
&lt;br /&gt;
1. Camera captures video frames&lt;br /&gt;
2. AI model detects vehicles&lt;br /&gt;
3. Each detected vehicle is counted&lt;br /&gt;
4. Vehicle movement between frames is tracked&lt;br /&gt;
5. Speed is estimated using distance and time&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Installation&lt;br /&gt;
&lt;br /&gt;
sudo apt update&lt;br /&gt;
sudo apt upgrade&lt;br /&gt;
sudo apt install python3-opencv python3-pip&lt;br /&gt;
pip3 install ultralytics&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
AI model&lt;br /&gt;
&lt;br /&gt;
A lightweight YOLO Nano model is used for vehicle detection.&lt;br /&gt;
The model is pre-trained and used only for inference.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Python code (copy-paste)&lt;br /&gt;
&lt;br /&gt;
import cv2&lt;br /&gt;
import time&lt;br /&gt;
import math&lt;br /&gt;
from ultralytics import YOLO&lt;br /&gt;
&lt;br /&gt;
model = YOLO(&amp;quot;yolov8n.pt&amp;quot;)&lt;br /&gt;
cap = cv2.VideoCapture(0)&lt;br /&gt;
&lt;br /&gt;
PIXELS_PER_METER = 60&lt;br /&gt;
prev_positions = {}&lt;br /&gt;
vehicle_id = 0&lt;br /&gt;
counted = set()&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ret, frame = cap.read()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if not ret:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;results = model(frame, verbose=False)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;boxes = results[0].boxes&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;current_time = time.time()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;current_positions = {}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for box in boxes:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x1, y1, x2, y2 = box.xyxy[0]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cx = int((x1 + x2) / 2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cy = int((y1 + y2) / 2)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;matched = False&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for vid, (px, py, pt) in prev_positions.items():&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dist = math.hypot(cx - px, cy - py)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if dist &amp;lt; 50:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;speed = (dist / PIXELS_PER_METER) / (current_time - pt)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;current_positions[vid] = (cx, cy, current_time)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;matched = True&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if not matched:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;current_positions[vehicle_id] = (cx, cy, current_time)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;counted.add(vehicle_id)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vehicle_id += 1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prev_positions = current_positions&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cv2.putText(frame, f&amp;quot;Vehicles counted: {len(counted)}&amp;quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(10, 30), cv2.FONT_HERSHEY_SIMPLEX,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.8, (0, 255, 0), 2)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cv2.imshow(&amp;quot;AI Traffic Analytics&amp;quot;, frame)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if cv2.waitKey(1) &amp;amp; 0xFF == 27:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;br /&gt;
&lt;br /&gt;
cap.release()&lt;br /&gt;
cv2.destroyAllWindows()&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
How it works&lt;br /&gt;
&lt;br /&gt;
Vehicles are detected using AI and represented by their center point.&lt;br /&gt;
By comparing movement between frames and measuring time differences,&lt;br /&gt;
the system estimates approximate speed.&lt;br /&gt;
&lt;br /&gt;
Counting is performed by assigning each detected vehicle a unique ID.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Calibration note&lt;br /&gt;
&lt;br /&gt;
The PIXELS_PER_METER value depends on camera position and scene scale.&lt;br /&gt;
It must be adjusted experimentally for realistic speed values.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Practical applications&lt;br /&gt;
&lt;br /&gt;
- Traffic flow monitoring&lt;br /&gt;
- Speed trend estimation&lt;br /&gt;
- Smart city prototypes&lt;br /&gt;
- Educational AI projects&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Limitations&lt;br /&gt;
&lt;br /&gt;
- Speed values are approximate&lt;br /&gt;
- Camera angle affects accuracy&lt;br /&gt;
- Not suitable for legal speed enforcement&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Conclusion&lt;br /&gt;
&lt;br /&gt;
This project demonstrates that meaningful traffic analytics can be built&lt;br /&gt;
on Raspberry Pi using AI, without expensive hardware or cloud services.&lt;br /&gt;
&lt;br /&gt;
Affordable hardware combined with smart software design enables&lt;br /&gt;
practical AI solutions.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/110/simple-ai-traffic-analytics-object-count-speed-on-raspberry</guid>
<pubDate>Sun, 04 Jan 2026 22:02:11 +0000</pubDate>
</item>
<item>
<title>ESP32 Motion Sensor Trigger → Raspberry Pi AI Vision</title>
<link>https://asky.uk/109/esp32-motion-sensor-trigger-%E2%86%92-raspberry-pi-ai-vision</link>
<description>&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQuByMilKuQhxatpOWvrseefdZS98yis0GbvA&amp;amp;s&quot; style=&quot;height:355px; width:632px&quot;&gt;&lt;br&gt;Hardware: ESP32 + Raspberry Pi 4 / 5&lt;br&gt;AI type: Hybrid AI (Sensor Trigger + Computer Vision)&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Overview&lt;br&gt;&lt;br&gt;This project demonstrates a hybrid AI system where an ESP32 with a motion sensor&lt;br&gt;acts as a low-power trigger, while a Raspberry Pi runs AI vision only when motion&lt;br&gt;is detected.&lt;br&gt;&lt;br&gt;This approach saves power and CPU resources by activating AI processing only&lt;br&gt;when needed.&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;What you build&lt;br&gt;&lt;br&gt;- ESP32 motion detection node&lt;br&gt;- Raspberry Pi AI vision system&lt;br&gt;- Wireless trigger via Wi-Fi&lt;br&gt;- Fully local processing&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Required hardware&lt;br&gt;&lt;br&gt;- ESP32 development board&lt;br&gt;- PIR motion sensor (HC-SR501 or compatible)&lt;br&gt;- Raspberry Pi 4 or Raspberry Pi 5&lt;br&gt;- Camera (Pi Camera or USB camera)&lt;br&gt;- Wi-Fi network&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Software requirements&lt;br&gt;&lt;br&gt;ESP32:&lt;br&gt;- Arduino IDE&lt;br&gt;- WiFi library&lt;br&gt;&lt;br&gt;Raspberry Pi:&lt;br&gt;- Raspberry Pi OS&lt;br&gt;- Python 3&lt;br&gt;- OpenCV&lt;br&gt;- Ultralytics YOLO&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;System architecture&lt;br&gt;&lt;br&gt;1. ESP32 monitors motion using a PIR sensor&lt;br&gt;2. When motion is detected, ESP32 sends a Wi-Fi message&lt;br&gt;3. Raspberry Pi receives the trigger&lt;br&gt;4. AI vision starts only on demand&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;ESP32 Arduino code (motion trigger)&lt;br&gt;&lt;br&gt;#include &amp;lt;WiFi.h&amp;gt;&lt;br&gt;&lt;br&gt;const char* ssid = &quot;YOUR_WIFI&quot;;&lt;br&gt;const char* password = &quot;YOUR_PASSWORD&quot;;&lt;br&gt;&lt;br&gt;const char* pi_ip = &quot;192.168.1.100&quot;;&lt;br&gt;const int pi_port = 5000;&lt;br&gt;&lt;br&gt;int pirPin = 13;&lt;br&gt;&lt;br&gt;void setup() {&lt;br&gt;&amp;nbsp; pinMode(pirPin, INPUT);&lt;br&gt;&amp;nbsp; Serial.begin(115200);&lt;br&gt;&lt;br&gt;&amp;nbsp; WiFi.begin(ssid, password);&lt;br&gt;&amp;nbsp; while (WiFi.status() != WL_CONNECTED) {&lt;br&gt;&amp;nbsp; &amp;nbsp; delay(500);&lt;br&gt;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;void loop() {&lt;br&gt;&amp;nbsp; if (digitalRead(pirPin) == HIGH) {&lt;br&gt;&amp;nbsp; &amp;nbsp; WiFiClient client;&lt;br&gt;&amp;nbsp; &amp;nbsp; if (client.connect(pi_ip, pi_port)) {&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; client.println(&quot;MOTION&quot;);&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; client.stop();&lt;br&gt;&amp;nbsp; &amp;nbsp; }&lt;br&gt;&amp;nbsp; &amp;nbsp; delay(3000);&lt;br&gt;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Raspberry Pi Python trigger listener&lt;br&gt;&lt;br&gt;import socket&lt;br&gt;import subprocess&lt;br&gt;&lt;br&gt;HOST = &quot;0.0.0.0&quot;&lt;br&gt;PORT = 5000&lt;br&gt;&lt;br&gt;sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br&gt;sock.bind((HOST, PORT))&lt;br&gt;sock.listen(1)&lt;br&gt;&lt;br&gt;print(&quot;Waiting for ESP32 trigger...&quot;)&lt;br&gt;&lt;br&gt;while True:&lt;br&gt;&amp;nbsp; &amp;nbsp; conn, addr = sock.accept()&lt;br&gt;&amp;nbsp; &amp;nbsp; data = conn.recv(1024).decode().strip()&lt;br&gt;&amp;nbsp; &amp;nbsp; if data == &quot;MOTION&quot;:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&quot;Motion detected - starting AI vision&quot;)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; subprocess.Popen([&quot;python3&quot;, &quot;ai_vision.py&quot;])&lt;br&gt;&amp;nbsp; &amp;nbsp; conn.close()&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Raspberry Pi AI vision example (ai_vision.py)&lt;br&gt;&lt;br&gt;import cv2&lt;br&gt;from ultralytics import YOLO&lt;br&gt;&lt;br&gt;model = YOLO(&quot;yolov8n.pt&quot;)&lt;br&gt;cap = cv2.VideoCapture(0)&lt;br&gt;&lt;br&gt;for i in range(100):&lt;br&gt;&amp;nbsp; &amp;nbsp; ret, frame = cap.read()&lt;br&gt;&amp;nbsp; &amp;nbsp; if not ret:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;br&gt;&amp;nbsp; &amp;nbsp; results = model(frame, verbose=False)&lt;br&gt;&amp;nbsp; &amp;nbsp; cv2.imshow(&quot;AI Vision&quot;, frame)&lt;br&gt;&amp;nbsp; &amp;nbsp; if cv2.waitKey(1) &amp;amp; 0xFF == 27:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;br&gt;&lt;br&gt;cap.release()&lt;br&gt;cv2.destroyAllWindows()&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;How it works&lt;br&gt;&lt;br&gt;The ESP32 continuously monitors motion with very low power usage.&lt;br&gt;When motion is detected, it sends a simple trigger message to the Raspberry Pi.&lt;br&gt;The Raspberry Pi then activates AI vision for a limited time.&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Practical applications&lt;br&gt;&lt;br&gt;- Smart surveillance systems&lt;br&gt;- Wildlife monitoring&lt;br&gt;- Energy-efficient AI cameras&lt;br&gt;- Security triggers&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Limitations&lt;br&gt;&lt;br&gt;- Requires Wi-Fi connectivity&lt;br&gt;- PIR detects motion, not object type&lt;br&gt;- AI runtime duration must be managed&lt;br&gt;&lt;br&gt;--------------------------------------------------&lt;br&gt;&lt;br&gt;Conclusion&lt;br&gt;&lt;br&gt;By combining ESP32 sensors with Raspberry Pi AI vision, efficient hybrid AI systems&lt;br&gt;can be built on affordable hardware.&lt;br&gt;&lt;br&gt;AI without millions is achieved through smart architecture, not expensive hardware.&lt;br&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/109/esp32-motion-sensor-trigger-%E2%86%92-raspberry-pi-ai-vision</guid>
<pubDate>Sun, 04 Jan 2026 22:00:20 +0000</pubDate>
</item>
<item>
<title>Line Crossing Counter with AI on Raspberry Pi (Entry / Exit Detection)</title>
<link>https://asky.uk/108/line-crossing-counter-with-raspberry-entry-exit-detection</link>
<description>&lt;p data-start=&quot;368&quot; data-end=&quot;417&quot;&gt;&lt;strong data-start=&quot;368&quot; data-end=&quot;417&quot;&gt;Line Crossing Counter with AI on Raspberry Pi&lt;/strong&gt;&lt;/p&gt;&lt;p data-start=&quot;419&quot; data-end=&quot;493&quot;&gt;Hardware: Raspberry Pi 4 / 5&lt;br data-start=&quot;447&quot; data-end=&quot;450&quot;&gt;AI type: Computer Vision – Object Detection&lt;/p&gt;&lt;hr data-start=&quot;495&quot; data-end=&quot;498&quot;&gt;&lt;p data-start=&quot;500&quot; data-end=&quot;512&quot;&gt;&lt;strong data-start=&quot;500&quot; data-end=&quot;512&quot;&gt;Overview&lt;/strong&gt;&lt;/p&gt;&lt;p data-start=&quot;514&quot; data-end=&quot;741&quot;&gt;This project shows how a Raspberry Pi can count entries and exits using AI.&lt;br data-start=&quot;589&quot; data-end=&quot;592&quot;&gt;Objects are detected by a lightweight AI model and counted when they cross a virtual line.&lt;br data-start=&quot;682&quot; data-end=&quot;685&quot;&gt;Everything runs locally, without cloud services or GPUs.&lt;/p&gt;&lt;hr data-start=&quot;743&quot; data-end=&quot;746&quot;&gt;&lt;p data-start=&quot;748&quot; data-end=&quot;766&quot;&gt;&lt;strong data-start=&quot;748&quot; data-end=&quot;766&quot;&gt;What you build&lt;/strong&gt;&lt;/p&gt;&lt;ul data-start=&quot;768&quot; data-end=&quot;883&quot;&gt;&lt;li data-start=&quot;768&quot; data-end=&quot;807&quot;&gt;&lt;p data-start=&quot;770&quot; data-end=&quot;807&quot;&gt;AI object detection on Raspberry Pi&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;808&quot; data-end=&quot;854&quot;&gt;&lt;p data-start=&quot;810&quot; data-end=&quot;854&quot;&gt;Entry / exit counting using a virtual line&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;855&quot; data-end=&quot;883&quot;&gt;&lt;p data-start=&quot;857&quot; data-end=&quot;883&quot;&gt;Fully offline processing&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;885&quot; data-end=&quot;888&quot;&gt;&lt;p data-start=&quot;890&quot; data-end=&quot;911&quot;&gt;&lt;strong data-start=&quot;890&quot; data-end=&quot;911&quot;&gt;Required hardware&lt;/strong&gt;&lt;/p&gt;&lt;ul data-start=&quot;913&quot; data-end=&quot;1000&quot;&gt;&lt;li data-start=&quot;913&quot; data-end=&quot;936&quot;&gt;&lt;p data-start=&quot;915&quot; data-end=&quot;936&quot;&gt;Raspberry Pi 4 or 5&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;937&quot; data-end=&quot;966&quot;&gt;&lt;p data-start=&quot;939&quot; data-end=&quot;966&quot;&gt;Camera (Pi Camera or USB)&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;967&quot; data-end=&quot;983&quot;&gt;&lt;p data-start=&quot;969&quot; data-end=&quot;983&quot;&gt;microSD card&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;984&quot; data-end=&quot;1000&quot;&gt;&lt;p data-start=&quot;986&quot; data-end=&quot;1000&quot;&gt;Power supply&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;1002&quot; data-end=&quot;1005&quot;&gt;&lt;p data-start=&quot;1007&quot; data-end=&quot;1019&quot;&gt;&lt;strong data-start=&quot;1007&quot; data-end=&quot;1019&quot;&gt;Software&lt;/strong&gt;&lt;/p&gt;&lt;ul data-start=&quot;1021&quot; data-end=&quot;1085&quot;&gt;&lt;li data-start=&quot;1021&quot; data-end=&quot;1040&quot;&gt;&lt;p data-start=&quot;1023&quot; data-end=&quot;1040&quot;&gt;Raspberry Pi OS&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1041&quot; data-end=&quot;1053&quot;&gt;&lt;p data-start=&quot;1043&quot; data-end=&quot;1053&quot;&gt;Python 3&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1054&quot; data-end=&quot;1064&quot;&gt;&lt;p data-start=&quot;1056&quot; data-end=&quot;1064&quot;&gt;OpenCV&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1065&quot; data-end=&quot;1085&quot;&gt;&lt;p data-start=&quot;1067&quot; data-end=&quot;1085&quot;&gt;Ultralytics YOLO&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;1087&quot; data-end=&quot;1090&quot;&gt;&lt;p data-start=&quot;1092&quot; data-end=&quot;1108&quot;&gt;&lt;strong data-start=&quot;1092&quot; data-end=&quot;1108&quot;&gt;Installation&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;overflow-visible! px-0!&quot; data-start=&quot;1110&quot; data-end=&quot;1219&quot;&gt;&lt;/pre&gt;&lt;div class=&quot;contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary&quot;&gt;&lt;/div&gt;&lt;pre class=&quot;overflow-visible! px-0!&quot; data-start=&quot;1110&quot; data-end=&quot;1219&quot;&gt;&lt;/pre&gt;&lt;div class=&quot;@w-xl/main:top-9 sticky top-[calc(--spacing(9)+var(--header-height))]&quot;&gt;&lt;div class=&quot;absolute end-0 bottom-0 flex h-9 items-center pe-2&quot;&gt;&lt;div class=&quot;bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre class=&quot;overflow-visible! px-0!&quot; data-start=&quot;1110&quot; data-end=&quot;1219&quot;&gt;&lt;/pre&gt;&lt;div class=&quot;contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary&quot;&gt;&lt;div class=&quot;overflow-y-auto p-4&quot; dir=&quot;ltr&quot;&gt;&lt;code class=&quot;whitespace-pre!&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt;&lt;/span&gt;&lt;span&gt; apt update &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt;&lt;/span&gt;&lt;span&gt; apt upgrade &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt;&lt;/span&gt;&lt;span&gt; apt install python3-opencv python3-pip pip3 install ultralytics &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;hr data-start=&quot;1221&quot; data-end=&quot;1224&quot;&gt;&lt;p data-start=&quot;1226&quot; data-end=&quot;1237&quot;&gt;&lt;strong data-start=&quot;1226&quot; data-end=&quot;1237&quot;&gt;Concept&lt;/strong&gt;&lt;/p&gt;&lt;p data-start=&quot;1239&quot; data-end=&quot;1393&quot;&gt;A horizontal virtual line is placed in the video frame.&lt;br data-start=&quot;1294&quot; data-end=&quot;1297&quot;&gt;When an object’s center crosses the line, it is counted as entry or exit depending on direction.&lt;/p&gt;&lt;hr data-start=&quot;1395&quot; data-end=&quot;1398&quot;&gt;&lt;p data-start=&quot;1400&quot; data-end=&quot;1428&quot;&gt;&lt;strong data-start=&quot;1400&quot; data-end=&quot;1428&quot;&gt;Python code (copy-paste)&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;overflow-visible! px-0!&quot; data-start=&quot;1430&quot; data-end=&quot;2471&quot;&gt;&lt;/pre&gt;&lt;div class=&quot;contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary&quot;&gt;&lt;/div&gt;&lt;pre class=&quot;overflow-visible! px-0!&quot; data-start=&quot;1430&quot; data-end=&quot;2471&quot;&gt;&lt;/pre&gt;&lt;div class=&quot;@w-xl/main:top-9 sticky top-[calc(--spacing(9)+var(--header-height))]&quot;&gt;&lt;div class=&quot;absolute end-0 bottom-0 flex h-9 items-center pe-2&quot;&gt;&lt;div class=&quot;bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre class=&quot;overflow-visible! px-0!&quot; data-start=&quot;1430&quot; data-end=&quot;2471&quot;&gt;&lt;/pre&gt;&lt;div class=&quot;contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary&quot;&gt;&lt;div class=&quot;overflow-y-auto p-4&quot; dir=&quot;ltr&quot;&gt;&lt;code class=&quot;whitespace-pre! language-python&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span&gt; cv2 &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt;&lt;/span&gt;&lt;span&gt; ultralytics &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span&gt; YOLO model = YOLO(&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;yolov8n.pt&quot;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) cap = cv2.VideoCapture(&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) line_y = &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;240&lt;/span&gt;&lt;/span&gt;&lt;span&gt; prev_y = &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;&lt;/span&gt;&lt;span&gt; entries = &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt; exits = &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-literal&quot;&gt;True&lt;/span&gt;&lt;/span&gt;&lt;span&gt;: ret, frame = cap.read() &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt;&lt;/span&gt;&lt;span&gt; ret: &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;&lt;/span&gt;&lt;span&gt; results = model(frame, verbose=&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-literal&quot;&gt;False&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) boxes = results[&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;].boxes &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;len&lt;/span&gt;&lt;/span&gt;&lt;span&gt;(boxes) &amp;gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;: x1, y1, x2, y2 = boxes[&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;].xyxy[&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;] cy = &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span&gt;((y1 + y2) / &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span&gt; prev_y &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;is&lt;/span&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;not&lt;/span&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-literal&quot;&gt;None&lt;/span&gt;&lt;/span&gt;&lt;span&gt;: &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span&gt; prev_y &amp;lt; line_y &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span&gt; cy &amp;gt;= line_y: entries += &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt;&lt;/span&gt;&lt;span&gt; prev_y &amp;gt; line_y &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span&gt; cy &amp;lt;= line_y: exits += &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span&gt; prev_y = cy cv2.line(frame, (&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, line_y), (frame.shape[&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span&gt;], line_y), (&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;255&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;), &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) cv2.putText(frame, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-string&quot;&gt;f&quot;Entries: &lt;span class=&quot;hljs-subst&quot;&gt;{entries}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&quot;, (&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;30&lt;/span&gt;&lt;/span&gt;&lt;span&gt;), cv2.FONT_HERSHEY_SIMPLEX, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0.8&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, (&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;255&lt;/span&gt;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;), &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) cv2.putText(frame, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-string&quot;&gt;f&quot;Exits: &lt;span class=&quot;hljs-subst&quot;&gt;{exits}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&quot;, (&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;60&lt;/span&gt;&lt;/span&gt;&lt;span&gt;), cv2.FONT_HERSHEY_SIMPLEX, &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0.8&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, (&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;255&lt;/span&gt;&lt;/span&gt;&lt;span&gt;), &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) cv2.imshow(&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;Line Counter&quot;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;, frame) &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span&gt; cv2.waitKey(&lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span&gt;) &amp;amp; &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0xFF&lt;/span&gt;&lt;/span&gt;&lt;span&gt; == &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-number&quot;&gt;27&lt;/span&gt;&lt;/span&gt;&lt;span&gt;: &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;break&lt;/span&gt;&lt;/span&gt;&lt;span&gt; cap.release() cv2.destroyAllWindows() &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;hr data-start=&quot;2473&quot; data-end=&quot;2476&quot;&gt;&lt;p data-start=&quot;2478&quot; data-end=&quot;2494&quot;&gt;&lt;strong data-start=&quot;2478&quot; data-end=&quot;2494&quot;&gt;Applications&lt;/strong&gt;&lt;/p&gt;&lt;ul data-start=&quot;2496&quot; data-end=&quot;2582&quot;&gt;&lt;li data-start=&quot;2496&quot; data-end=&quot;2526&quot;&gt;&lt;p data-start=&quot;2498&quot; data-end=&quot;2526&quot;&gt;People entry/exit counting&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;2527&quot; data-end=&quot;2553&quot;&gt;&lt;p data-start=&quot;2529&quot; data-end=&quot;2553&quot;&gt;Store traffic analysis&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;2554&quot; data-end=&quot;2582&quot;&gt;&lt;p data-start=&quot;2556&quot; data-end=&quot;2582&quot;&gt;Simple access monitoring&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;2584&quot; data-end=&quot;2587&quot;&gt;&lt;p data-start=&quot;2589&quot; data-end=&quot;2604&quot;&gt;&lt;strong data-start=&quot;2589&quot; data-end=&quot;2604&quot;&gt;Limitations&lt;/strong&gt;&lt;/p&gt;&lt;ul data-start=&quot;2606&quot; data-end=&quot;2672&quot;&gt;&lt;li data-start=&quot;2606&quot; data-end=&quot;2641&quot;&gt;&lt;p data-start=&quot;2608&quot; data-end=&quot;2641&quot;&gt;Works best with one main object&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;2642&quot; data-end=&quot;2672&quot;&gt;&lt;p data-start=&quot;2644&quot; data-end=&quot;2672&quot;&gt;Occlusions reduce accuracy&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;2674&quot; data-end=&quot;2677&quot;&gt;&lt;p data-start=&quot;2679&quot; data-end=&quot;2693&quot;&gt;&lt;strong data-start=&quot;2679&quot; data-end=&quot;2693&quot;&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;&lt;p data-start=&quot;2695&quot; data-end=&quot;2863&quot;&gt;Raspberry Pi can perform practical AI analytics like entry and exit counting without expensive hardware.&lt;br data-start=&quot;2799&quot; data-end=&quot;2802&quot;&gt;This is a real, deployable AI use case on affordable devices.&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/108/line-crossing-counter-with-raspberry-entry-exit-detection</guid>
<pubDate>Sun, 21 Dec 2025 21:03:34 +0000</pubDate>
</item>
<item>
<title>Speed estimation with AI on Raspberry Pi</title>
<link>https://asky.uk/107/speed-estimation-with-ai-on-raspberry-pi</link>
<description>&lt;p data-start=&quot;374&quot; data-end=&quot;473&quot;&gt;Hardware: Raspberry Pi 4 / Raspberry Pi 5&lt;br data-start=&quot;415&quot; data-end=&quot;418&quot;&gt;AI type: Computer Vision – Detection + Speed Estimation&lt;/p&gt;&lt;hr data-start=&quot;475&quot; data-end=&quot;478&quot;&gt;&lt;p data-start=&quot;480&quot; data-end=&quot;488&quot;&gt;Overview&lt;/p&gt;&lt;p data-start=&quot;490&quot; data-end=&quot;705&quot;&gt;This project shows how a Raspberry Pi can estimate the speed of moving objects using AI-based object detection and simple motion analysis.&lt;br data-start=&quot;628&quot; data-end=&quot;631&quot;&gt;The system runs fully offline and does not require GPUs or cloud services.&lt;/p&gt;&lt;p data-start=&quot;707&quot; data-end=&quot;814&quot;&gt;The goal is not absolute precision, but a practical and reproducible AI approach using affordable hardware.&lt;/p&gt;&lt;hr data-start=&quot;816&quot; data-end=&quot;819&quot;&gt;&lt;p data-start=&quot;821&quot; data-end=&quot;840&quot;&gt;What you will build&lt;/p&gt;&lt;ul data-start=&quot;842&quot; data-end=&quot;1015&quot;&gt;&lt;li data-start=&quot;842&quot; data-end=&quot;887&quot;&gt;&lt;p data-start=&quot;844&quot; data-end=&quot;887&quot;&gt;AI-based object detection on Raspberry Pi&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;888&quot; data-end=&quot;930&quot;&gt;&lt;p data-start=&quot;890&quot; data-end=&quot;930&quot;&gt;Tracking object movement across frames&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;931&quot; data-end=&quot;988&quot;&gt;&lt;p data-start=&quot;933&quot; data-end=&quot;988&quot;&gt;Estimating object speed using pixel distance and time&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;989&quot; data-end=&quot;1015&quot;&gt;&lt;p data-start=&quot;991&quot; data-end=&quot;1015&quot;&gt;Fully local processing&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;1017&quot; data-end=&quot;1020&quot;&gt;&lt;p data-start=&quot;1022&quot; data-end=&quot;1039&quot;&gt;Required hardware&lt;/p&gt;&lt;ul data-start=&quot;1041&quot; data-end=&quot;1149&quot;&gt;&lt;li data-start=&quot;1041&quot; data-end=&quot;1077&quot;&gt;&lt;p data-start=&quot;1043&quot; data-end=&quot;1077&quot;&gt;Raspberry Pi 4 or Raspberry Pi 5&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1078&quot; data-end=&quot;1115&quot;&gt;&lt;p data-start=&quot;1080&quot; data-end=&quot;1115&quot;&gt;Raspberry Pi Camera or USB camera&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1116&quot; data-end=&quot;1132&quot;&gt;&lt;p data-start=&quot;1118&quot; data-end=&quot;1132&quot;&gt;microSD card&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1133&quot; data-end=&quot;1149&quot;&gt;&lt;p data-start=&quot;1135&quot; data-end=&quot;1149&quot;&gt;Power supply&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;1151&quot; data-end=&quot;1154&quot;&gt;&lt;p data-start=&quot;1156&quot; data-end=&quot;1177&quot;&gt;Software requirements&lt;/p&gt;&lt;ul data-start=&quot;1179&quot; data-end=&quot;1263&quot;&gt;&lt;li data-start=&quot;1179&quot; data-end=&quot;1198&quot;&gt;&lt;p data-start=&quot;1181&quot; data-end=&quot;1198&quot;&gt;Raspberry Pi OS&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1199&quot; data-end=&quot;1211&quot;&gt;&lt;p data-start=&quot;1201&quot; data-end=&quot;1211&quot;&gt;Python 3&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1212&quot; data-end=&quot;1222&quot;&gt;&lt;p data-start=&quot;1214&quot; data-end=&quot;1222&quot;&gt;OpenCV&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1223&quot; data-end=&quot;1263&quot;&gt;&lt;p data-start=&quot;1225&quot; data-end=&quot;1263&quot;&gt;Ultralytics YOLO (lightweight model)&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;1265&quot; data-end=&quot;1268&quot;&gt;&lt;p data-start=&quot;1270&quot; data-end=&quot;1290&quot;&gt;Project architecture&lt;/p&gt;&lt;ol data-start=&quot;1292&quot; data-end=&quot;1438&quot;&gt;&lt;li data-start=&quot;1292&quot; data-end=&quot;1325&quot;&gt;&lt;p data-start=&quot;1295&quot; data-end=&quot;1325&quot;&gt;Camera captures video frames&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1326&quot; data-end=&quot;1355&quot;&gt;&lt;p data-start=&quot;1329&quot; data-end=&quot;1355&quot;&gt;AI model detects objects&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1356&quot; data-end=&quot;1389&quot;&gt;&lt;p data-start=&quot;1359&quot; data-end=&quot;1389&quot;&gt;Object positions are tracked&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;1390&quot; data-end=&quot;1438&quot;&gt;&lt;p data-start=&quot;1393&quot; data-end=&quot;1438&quot;&gt;Speed is calculated from movement over time&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr data-start=&quot;1440&quot; data-end=&quot;1443&quot;&gt;&lt;p data-start=&quot;1445&quot; data-end=&quot;1463&quot;&gt;Installation steps&lt;/p&gt;&lt;p data-start=&quot;1465&quot; data-end=&quot;1504&quot;&gt;Update system and install dependencies:&lt;/p&gt;&lt;p data-start=&quot;1465&quot; data-end=&quot;1504&quot;&gt;sudo apt update&lt;br&gt;sudo apt upgrade&lt;br&gt;sudo apt install python3-opencv python3-pip&lt;br&gt;pip3 install ultralytics&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;p data-start=&quot;1626&quot; data-end=&quot;1641&quot;&gt;AI model choice&lt;/p&gt;&lt;p data-start=&quot;1643&quot; data-end=&quot;1751&quot;&gt;A lightweight YOLO Nano model is used for detection.&lt;br data-start=&quot;1695&quot; data-end=&quot;1698&quot;&gt;The model is pre-trained and used only for inference.&lt;/p&gt;&lt;p data-start=&quot;1643&quot; data-end=&quot;1751&quot;&gt;import cv2&lt;br&gt;from ultralytics import YOLO&lt;br&gt;import time&lt;br&gt;import math&lt;br&gt;&lt;br&gt;model = YOLO(&quot;yolov8n.pt&quot;)&lt;br&gt;cap = cv2.VideoCapture(0)&lt;br&gt;&lt;br&gt;prev_pos = None&lt;br&gt;prev_time = None&lt;br&gt;speed = 0&lt;br&gt;&lt;br&gt;PIXELS_PER_METER = 50&amp;nbsp; # calibration value&lt;br&gt;&lt;br&gt;while True:&lt;br&gt;&amp;nbsp; &amp;nbsp; ret, frame = cap.read()&lt;br&gt;&amp;nbsp; &amp;nbsp; if not ret:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; results = model(frame, verbose=False)&lt;br&gt;&amp;nbsp; &amp;nbsp; boxes = results[0].boxes&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; if len(boxes) &amp;gt; 0:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x1, y1, x2, y2 = boxes[0].xyxy[0]&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cx = int((x1 + x2) / 2)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cy = int((y1 + y2) / 2)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current_time = time.time()&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if prev_pos is not None:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dist_pixels = math.hypot(cx - prev_pos[0], cy - prev_pos[1])&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dist_meters = dist_pixels / PIXELS_PER_METER&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt = current_time - prev_time&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if dt &amp;gt; 0:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; speed = dist_meters / dt&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prev_pos = (cx, cy)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prev_time = current_time&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cv2.circle(frame, (cx, cy), 5, (0, 255, 0), -1)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; cv2.putText(frame, f&quot;Speed: {speed:.2f} m/s&quot;,&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (10, 30), cv2.FONT_HERSHEY_SIMPLEX,&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1, (0, 255, 0), 2)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; cv2.imshow(&quot;AI Speed Estimation&quot;, frame)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; if cv2.waitKey(1) &amp;amp; 0xFF == 27:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;br&gt;&lt;br&gt;cap.release()&lt;br&gt;cv2.destroyAllWindows()&lt;/p&gt;&lt;p data-start=&quot;2982&quot; data-end=&quot;2994&quot;&gt;How it works&lt;/p&gt;&lt;p data-start=&quot;2996&quot; data-end=&quot;3232&quot;&gt;The AI model detects an object and extracts its center position.&lt;br data-start=&quot;3060&quot; data-end=&quot;3063&quot;&gt;The distance between positions across frames is measured in pixels and converted to meters using a calibration factor.&lt;br data-start=&quot;3181&quot; data-end=&quot;3184&quot;&gt;Speed is calculated as distance divided by time.&lt;/p&gt;&lt;hr data-start=&quot;3234&quot; data-end=&quot;3237&quot;&gt;&lt;p data-start=&quot;3239&quot; data-end=&quot;3255&quot;&gt;Calibration note&lt;/p&gt;&lt;p data-start=&quot;3257&quot; data-end=&quot;3385&quot;&gt;The PIXELS_PER_METER value depends on camera position and scene scale.&lt;br data-start=&quot;3327&quot; data-end=&quot;3330&quot;&gt;It must be adjusted experimentally for better accuracy.&lt;/p&gt;&lt;hr data-start=&quot;3387&quot; data-end=&quot;3390&quot;&gt;&lt;p data-start=&quot;3392&quot; data-end=&quot;3414&quot;&gt;Practical applications&lt;/p&gt;&lt;ul data-start=&quot;3416&quot; data-end=&quot;3527&quot;&gt;&lt;li data-start=&quot;3416&quot; data-end=&quot;3444&quot;&gt;&lt;p data-start=&quot;3418&quot; data-end=&quot;3444&quot;&gt;Traffic speed monitoring&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;3445&quot; data-end=&quot;3470&quot;&gt;&lt;p data-start=&quot;3447&quot; data-end=&quot;3470&quot;&gt;Robot motion analysis&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;3471&quot; data-end=&quot;3499&quot;&gt;&lt;p data-start=&quot;3473&quot; data-end=&quot;3499&quot;&gt;Conveyor belt monitoring&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;3500&quot; data-end=&quot;3527&quot;&gt;&lt;p data-start=&quot;3502&quot; data-end=&quot;3527&quot;&gt;Educational AI projects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;3529&quot; data-end=&quot;3532&quot;&gt;&lt;p data-start=&quot;3534&quot; data-end=&quot;3545&quot;&gt;Limitations&lt;/p&gt;&lt;ul data-start=&quot;3547&quot; data-end=&quot;3674&quot;&gt;&lt;li data-start=&quot;3547&quot; data-end=&quot;3579&quot;&gt;&lt;p data-start=&quot;3549&quot; data-end=&quot;3579&quot;&gt;Approximate speed estimation&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;3580&quot; data-end=&quot;3625&quot;&gt;&lt;p data-start=&quot;3582&quot; data-end=&quot;3625&quot;&gt;Sensitive to camera angle and calibration&lt;/p&gt;&lt;/li&gt;&lt;li data-start=&quot;3626&quot; data-end=&quot;3674&quot;&gt;&lt;p data-start=&quot;3628&quot; data-end=&quot;3674&quot;&gt;Not suitable for high-precision measurements&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr data-start=&quot;3676&quot; data-end=&quot;3679&quot;&gt;&lt;p data-start=&quot;3681&quot; data-end=&quot;3691&quot;&gt;Conclusion&lt;/p&gt;&lt;p data-start=&quot;3693&quot; data-end=&quot;3916&quot;&gt;This project demonstrates that Raspberry Pi can perform meaningful AI-based speed estimation without GPUs or cloud services.&lt;br data-start=&quot;3817&quot; data-end=&quot;3820&quot;&gt;With lightweight models and simple math, affordable hardware can deliver practical AI solutions.&lt;/p&gt;&lt;p data-start=&quot;3918&quot; data-end=&quot;3969&quot;&gt;AI without millions remains an engineering reality.&lt;/p&gt;&lt;p data-start=&quot;1643&quot; data-end=&quot;1751&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://i.ytimg.com/vi/n2WT3Qb0SIU/maxresdefault.jpg&quot; style=&quot;height:506px; width:900px&quot;&gt;&lt;/p&gt;&lt;p data-start=&quot;1465&quot; data-end=&quot;1504&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/107/speed-estimation-with-ai-on-raspberry-pi</guid>
<pubDate>Fri, 19 Dec 2025 07:22:17 +0000</pubDate>
</item>
<item>
<title>Object Tracking and Unique Counting with AI on Raspberry Pi</title>
<link>https://asky.uk/106/object-tracking-and-unique-counting-with-ai-on-raspberry-pi</link>
<description>&lt;p&gt;Hardware: Raspberry Pi 4 / Raspberry Pi 5&lt;br&gt;AI type: Computer Vision – Object Detection + Tracking&lt;/p&gt;&lt;p&gt;Overview&lt;/p&gt;&lt;p&gt;Simple object counting detects how many objects appear in a frame, but it cannot distinguish between new and already seen objects.&lt;br&gt;This project extends basic AI detection by adding object tracking, allowing the Raspberry Pi to count each object only once.&lt;/p&gt;&lt;p&gt;The result is a more practical AI system suitable for real-world scenarios such as people flow monitoring or vehicle counting.&lt;/p&gt;&lt;p&gt;What you will build&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;AI-based object detection on Raspberry Pi&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Object tracking across video frames&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Unique object counting (count once per object)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Fully local and offline system&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Required hardware&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi 4 or Raspberry Pi 5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi Camera or USB camera&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;microSD card&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Power supply&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Software requirements&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi OS&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Python 3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;OpenCV&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Ultralytics YOLO (lightweight model)&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Project architecture&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;Camera captures video frames&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;AI model detects objects in each frame&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Tracker assigns IDs to detected objects&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Each object ID is counted only once&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;This avoids double counting and improves accuracy.&lt;/p&gt;&lt;p&gt;Installation steps&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;Update system&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;sudo apt update sudo apt upgrade&lt;/p&gt;&lt;ol start=&quot;2&quot;&gt;&lt;li&gt;&lt;p&gt;Install dependencies&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;sudo apt install python3-opencv python3-pip pip3 install ultralytics&lt;/p&gt;&lt;ol start=&quot;3&quot;&gt;&lt;li&gt;&lt;p&gt;Reboot the system&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;AI model and tracking method&lt;/p&gt;&lt;p&gt;This project uses a lightweight YOLO model for detection and a simple centroid-based tracking logic.&lt;br&gt;Each detected object is assigned an ID based on its position across frames.&lt;/p&gt;&lt;p&gt;This approach is computationally efficient and suitable for Raspberry Pi hardware.&lt;/p&gt;&lt;hr&gt;&lt;p&gt;Python code (copy-paste)&lt;/p&gt;&lt;p&gt;import cv2 from ultralytics import YOLO import math model = YOLO(&quot;yolov8n.pt&quot;) cap = cv2.VideoCapture(0) object_id = 0 objects = {} counted_ids = set() def distance(p1, p2): return math.hypot(p1[0] - p2[0], p1[1] - p2[1]) while True: ret, frame = cap.read() if not ret: break results = model(frame, verbose=False) boxes = results[0].boxes current_centroids = [] for box in boxes: x1, y1, x2, y2 = box.xyxy[0] cx = int((x1 + x2) / 2) cy = int((y1 + y2) / 2) current_centroids.append((cx, cy)) for centroid in current_centroids: matched = False for oid, prev in objects.items(): if distance(centroid, prev) &amp;lt; 50: objects[oid] = centroid matched = True break if not matched: objects[object_id] = centroid counted_ids.add(object_id) object_id += 1 for oid, (cx, cy) in objects.items(): cv2.circle(frame, (cx, cy), 5, (0, 255, 0), -1) cv2.putText(frame, f&quot;ID {oid}&quot;, (cx + 5, cy + 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1) cv2.putText(frame, f&quot;Unique count: {len(counted_ids)}&quot;, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2) cv2.imshow(&quot;AI Object Tracking&quot;, frame) if cv2.waitKey(1) &amp;amp; 0xFF == 27: break cap.release() cv2.destroyAllWindows()&lt;/p&gt;&lt;hr&gt;&lt;p&gt;How it works&lt;/p&gt;&lt;p&gt;Each detected object is represented by its centroid.&lt;br&gt;The system compares centroids between frames and assigns the same ID if the distance is below a threshold.&lt;/p&gt;&lt;p&gt;When a new object appears, it receives a new ID and is counted only once.&lt;/p&gt;&lt;p&gt;This simple tracking logic avoids the complexity of advanced trackers while remaining effective.&lt;/p&gt;&lt;p&gt;Performance notes&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Works best with moderate object movement&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;High-speed motion may cause ID switching&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Lower camera resolution improves stabilit&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Practical application&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;People flow analysis&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Vehicle counting&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Queue monitoring&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Entrance and exit statistics&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Smart surveillance prototypes&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Limitations&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Simple tracker may lose objects during occlusion&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Not suitable for dense crowds&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Advanced tracking requires more compute&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Despite this, the solution is ideal for low-cost AI systems.&lt;/p&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;p&gt;By combining AI detection and lightweight tracking, Raspberry Pi becomes capable of unique object counting without GPUs or cloud services.&lt;br&gt;This project demonstrates how far affordable hardware can go with the right software architecture.&lt;/p&gt;&lt;p&gt;AI without millions is not a compromise — it is a design choice.&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://i.ytimg.com/vi/Pss9QSfhnDQ/hq720.jpg?sqp=-oaymwEhCK4FEIIDSFryq4qpAxMIARUAAAAAGAElAADIQj0AgKJD&amp;amp;rs=AOn4CLDsoVWh4-b-8ZKjnqK6K4gVJrJVfw&quot; style=&quot;height:386px; width:686px&quot;&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/106/object-tracking-and-unique-counting-with-ai-on-raspberry-pi</guid>
<pubDate>Thu, 18 Dec 2025 05:05:44 +0000</pubDate>
</item>
<item>
<title>Object Counting with AI on Raspberry Pi (Offline Computer Vision)</title>
<link>https://asky.uk/105/object-counting-with-ai-raspberry-offline-computer-vision</link>
<description>&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://intelgic.com/static/img/object-detection-tracking-counting2.jpg&quot; style=&quot;height:427px; width:758px&quot;&gt;&lt;/p&gt;&lt;p&gt;Hardware: Raspberry Pi 4 / Raspberry Pi 5&lt;br&gt;AI type: Computer Vision – Object Detection and Counting&lt;/p&gt;&lt;p&gt;Overview&lt;/p&gt;&lt;p&gt;This project demonstrates how a Raspberry Pi can be used to run an AI-based object detection system that counts objects in real time using a camera.&lt;br&gt;The system works locally, without cloud services or GPUs, proving that practical computer vision projects are possible on affordable hardware.&lt;/p&gt;&lt;p&gt;The focus is not on large models or high accuracy benchmarks, but on a functional and reproducible AI pipeline.&lt;/p&gt;&lt;p&gt;What you will build&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi running AI-based object detection&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Real-time object counting from a camera feed&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Fully local inference (offline)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Simple Python-based setup&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Required hardware&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi 4 or Raspberry Pi 5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi Camera Module or USB camera&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;microSD card (16GB or larger)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Power supply&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Software requirements&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi OS (64-bit recommended)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Python 3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;OpenCV&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Pre-trained lightweight object detection model&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Project architecture&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;Camera captures video frames&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Frames are processed locally on Raspberry Pi&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;AI model detects objects in each frame&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Objects are counted and displayed in real time&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;All processing happens on the Raspberry Pi.&lt;/p&gt;&lt;p&gt;Installation steps&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;Update the system&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;sudo apt update sudo apt upgrade&lt;/p&gt;&lt;ol start=&quot;2&quot;&gt;&lt;li&gt;&lt;p&gt;Install required packages&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;sudo apt install python3-opencv python3-pip pip3 install ultralytics&lt;/p&gt;&lt;ol start=&quot;3&quot;&gt;&lt;li&gt;&lt;p&gt;Reboot the Raspberry Pi&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr&gt;&lt;p&gt;AI model selection&lt;/p&gt;&lt;p&gt;For this project, a lightweight YOLO model is used.&lt;br&gt;YOLO Nano or YOLOv8 Nano variants are suitable for Raspberry Pi due to their low computational requirements.&lt;/p&gt;&lt;p&gt;The model is pre-trained and used only for inference.&lt;/p&gt;&lt;hr&gt;&lt;p&gt;Python code :&lt;/p&gt;&lt;p&gt;import cv2&lt;br&gt;from ultralytics import YOLO&lt;br&gt;&lt;br&gt;# Load lightweight YOLO model&lt;br&gt;model = YOLO(&quot;yolov8n.pt&quot;)&lt;br&gt;&lt;br&gt;# Open camera&lt;br&gt;cap = cv2.VideoCapture(0)&lt;br&gt;&lt;br&gt;while True:&lt;br&gt;&amp;nbsp; &amp;nbsp; ret, frame = cap.read()&lt;br&gt;&amp;nbsp; &amp;nbsp; if not ret:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; # Run inference&lt;br&gt;&amp;nbsp; &amp;nbsp; results = model(frame, verbose=False)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; # Extract detections&lt;br&gt;&amp;nbsp; &amp;nbsp; boxes = results[0].boxes&lt;br&gt;&amp;nbsp; &amp;nbsp; count = len(boxes)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; # Display object count&lt;br&gt;&amp;nbsp; &amp;nbsp; cv2.putText(&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; frame,&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f&quot;Objects detected: {count}&quot;,&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (10, 30),&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cv2.FONT_HERSHEY_SIMPLEX,&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1,&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (0, 255, 0),&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;br&gt;&amp;nbsp; &amp;nbsp; )&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; cv2.imshow(&quot;Object Counting AI&quot;, frame)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; if cv2.waitKey(1) &amp;amp; 0xFF == 27:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;br&gt;&lt;br&gt;cap.release()&lt;br&gt;cv2.destroyAllWindows()&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;How it works&lt;/p&gt;&lt;p&gt;Each video frame captured by the camera is passed to the YOLO model running on the Raspberry Pi.&lt;br&gt;The model detects objects in the frame and returns bounding boxes.&lt;br&gt;The number of detected objects is counted and displayed in real time.&lt;/p&gt;&lt;p&gt;This approach does not require object tracking and keeps the system simple and efficient.&lt;/p&gt;&lt;p&gt;Performance notes&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi 4: approximately 3–6 FPS depending on resolution&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi 5: higher and more stable frame rates&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Lower camera resolution improves performance&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Practical applications&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;People counting&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Vehicle counting&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Inventory monitoring&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Simple security and monitoring systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Educational computer vision projects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Limitations&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Limited frame rate compared to GPU systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Reduced accuracy for small or distant objects&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Not suitable for large or complex models&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These limitations are expected and acceptable for low-cost AI systems&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/105/object-counting-with-ai-raspberry-offline-computer-vision</guid>
<pubDate>Wed, 17 Dec 2025 05:16:32 +0000</pubDate>
</item>
<item>
<title>AI Without Millions: Real Intelligent Projects on Raspberry Pi and ESP32</title>
<link>https://asky.uk/103/without-millions-real-intelligent-projects-raspberry-esp32</link>
<description>&lt;h3&gt;Artificial Intelligence Is Not Just for Corporations&lt;/h3&gt;&lt;div&gt;&lt;img alt=&quot;&quot; src=&quot;https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQlcz8qPNicklILW5pVpMIj9sD1mTUTcqwRHA&amp;amp;s&quot; style=&quot;height:168px; width:300px&quot;&gt;&lt;/div&gt;&lt;p&gt;AI is often associated with GPU clusters, cloud services, and large budgets. This perception suggests that meaningful AI projects are out of reach for individuals and small teams. In reality, modern low-cost hardware enables fully functional intelligent systems without significant financial investment.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Raspberry Pi as an AI Platform&lt;/h3&gt;&lt;p&gt;Raspberry Pi 4 and Pi 5 provide enough computing power for local AI inference. They are commonly used for:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;computer vision (OpenCV, YOLO Nano variants)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;audio and signal analysis&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;intelligent systems without constant internet access&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;hybrid AI architectures with local decision-making&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;While Raspberry Pi is not designed for training large models, it is highly effective for running them.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;ESP32: AI on a Microcontroller&lt;/h3&gt;&lt;p&gt;ESP32 expands what is possible on a microcontroller. Using TensorFlow Lite Micro and Edge Impulse, ESP32-based systems can perform:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;image classification on ESP32-CAM&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;keyword spotting&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;sensor data classification&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;anomaly detection&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These capabilities come with very low power consumption and extremely low hardware cost.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;What Makes a Project “AI”&lt;/h3&gt;&lt;p&gt;An AI project is defined by intelligent behavior, not by model size. Common patterns include:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;local inference&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;hybrid rule-based and ML systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;distributed intelligence across devices&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;fallback logic for robustness&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;A typical example is an ESP32 detecting an event and forwarding data to a Raspberry Pi for higher-level processing.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Practical Applications Without Large Budgets&lt;/h3&gt;&lt;p&gt;Such systems are already used for:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;privacy-friendly local video monitoring&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;early fault detection&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;intelligent alarm systems&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;autonomous sensor nodes&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;They deliver real functionality without expensive infrastructure.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Constraints Are Part of Engineering&lt;/h3&gt;&lt;p&gt;Low-cost AI systems come with limitations: smaller models, constrained memory, and the need for careful optimization. These constraints shift the focus from budget to engineering skill.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;&lt;p&gt;Artificial intelligence is no longer exclusive to large corporations. With affordable hardware and thoughtful system design, real AI projects can be built without millions in funding.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/103/without-millions-real-intelligent-projects-raspberry-esp32</guid>
<pubDate>Mon, 15 Dec 2025 07:49:34 +0000</pubDate>
</item>
<item>
<title>How I Built an AI-Powered Multi-Language Currency Converter and Hosted It on a Raspberry Pi</title>
<link>https://asky.uk/102/built-powered-language-currency-converter-hosted-raspberry</link>
<description>&lt;p&gt;Many people use Raspberry Pi for small experiments, but it can also run real web services when combined with modern AI tools. One of the newest features on &lt;strong&gt;asky.uk&lt;/strong&gt; is a multi-language euro currency converter that was designed with the help of AI and runs entirely on a Raspberry Pi.&lt;/p&gt;&lt;p&gt;This article explains how the tool was created, how it works, and why it fits perfectly into the platform’s mission of combining AI and low-cost hardware.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;Idea and Goals&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;The converter needed to be:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;fast and lightweight&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;multilingual&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;minimalistic in design&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;accurate (using ECB reference rates)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;fully autonomous&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;hosted on a Raspberry Pi 2 without external cloud services&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The goal was to demonstrate that a real, useful web service can be developed with AI assistance and deployed on extremely small hardware.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;How AI Helped Build It&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;AI was used to generate most of the converter:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;HTML, CSS, and responsive layout&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;JavaScript logic for EUR ⇄ national currencies&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;translations into seven languages&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;dark/light themes&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;flag icons and UI structure&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;a Python script to download and store ECB rates daily&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This dramatically reduced development time and produced clean, efficient code suited for low-power devices.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;Automatic Updates via Raspberry Pi&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;The converter retrieves fresh exchange rates from the European Central Bank.&lt;br&gt;A daily cron job on the Raspberry Pi:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;downloads the newest rates&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;writes them to rates.json&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;updates timestamps&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;keeps the tool fully autonomous&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;No external database or manual updates are required.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;Hosting on Raspberry Pi&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;The entire service runs on a &lt;strong&gt;Raspberry Pi 2&lt;/strong&gt; using Apache2 and Let’s Encrypt SSL. Even this older Pi model easily handles:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;real-time conversions&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;multi-language UI&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;dark mode&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;fast static hosting&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;AdSense integration&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This proves that small devices can power real, production-ready web applications when the code is optimized.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;Multi-Language Support&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;The interface includes translations for:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;English&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Bulgarian&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Czech&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Polish&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Hungarian&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Romanian&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Turkish&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The converter automatically selects the correct language using browser settings (and optionally IP), allowing people from different countries to use it in their native language.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;Design and Speed Optimization&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;The converter is built as a single static HTML file:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;no frameworks&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;no server-side rendering&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;almost instant load time&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;excellent mobile performance&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;optional AMP version&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This approach improves SEO and ensures the site works smoothly even on older phones.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;Part of a Larger AI + Raspberry Pi Project&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;asky.uk focuses on projects created with or enhanced by AI.&lt;br&gt;This converter is part of a broader effort to:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;build small AI-assisted tools&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;host them on Raspberry Pi devices&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;demonstrate how modern AI can simplify coding, automation, and deployment&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;It shows how AI can turn a simple idea into a complete, autonomous service running entirely on your own hardware.&lt;/p&gt;&lt;h2&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;The euro currency converter is a practical example of what can be achieved when AI technology and Raspberry Pi hardware are combined.&lt;br&gt;It is fast, multilingual, self-updating, and completely self-hosted — a perfect demonstration of the direction in which asky.uk continues to evolve:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;lightweight, intelligent, AI-built tools running on small, affordable hardware.&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a rel=&quot;nofollow&quot; href=&quot;https://asky.uk/convertor/&quot;&gt;CONVERTOR&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://globalfintechseries.com/wp-content/uploads/AI-and-Machine-Learning_-Transforming-Payment-Systems-and-Global-Money-Exchange-4-960x720.jpg&quot; style=&quot;height:440px; width:588px&quot;&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/102/built-powered-language-currency-converter-hosted-raspberry</guid>
<pubDate>Sat, 29 Nov 2025 21:47:43 +0000</pubDate>
</item>
<item>
<title>Have you tried Manus yet?</title>
<link>https://asky.uk/101/have-you-tried-manus-yet</link>
<description>&lt;p&gt;One of the perfect AI tools through which you can bring any of your projects to success&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://manus.im/invitation/UZB1H0LZDHLS&quot;&gt;MANUS&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/101/have-you-tried-manus-yet</guid>
<pubDate>Sat, 15 Nov 2025 15:43:17 +0000</pubDate>
</item>
<item>
<title>Monetizing a Asky AI Bot</title>
<link>https://asky.uk/100/monetizing-a-asky-ai-bot</link>
<description>&lt;p&gt;Building an &lt;a rel=&quot;nofollow&quot; href=&quot;https://asky.uk/76/welcome-to-asky-ai-raspberry-pi-2-power&quot;&gt;&lt;strong&gt;AI-powered project&lt;/strong&gt; &lt;/a&gt;such as an HTML/CSS generator is fun, but turning it into a sustainable source of income requires clear monetization strategies. If you don’t want to rely solely on AdSense, here are practical alternatives that don’t require user accounts or heavy data collection (important for GDPR and privacy compliance).&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;1. &lt;strong&gt;One-Time Digital Product Sales&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;Instead of subscriptions, you can package outputs as downloadable assets:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Static bundles&lt;/strong&gt;: pre-designed templates, CSS themes, or landing page packs.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Customized bundles&lt;/strong&gt;: the app generates a ZIP file tailored to the user’s description.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;em&gt;Implementation&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Use Stripe Checkout, PayPal Buy Now, or Gumroad/Payhip for transactions.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Deliver via expiring download links (e.g., valid for 1 hour).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Price range: £1–£10 for small templates, £10–£30 for bundles.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This model is simple, requires minimal personal data, and is compatible with small traffic volumes.&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;2. &lt;strong&gt;Freemium With Pay-Per-Use&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;Keep the app free for light use, but charge for “power features”:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;More than 1–2 generations per day.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Access to advanced templates (responsive, dark/light modes).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Direct code download (instead of copy/paste).&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;em&gt;Implementation&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Add a “Buy More Generations” button.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Stripe Payment Links can sell credits (e.g., 20 generations for £5).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;No accounts: you can deliver credits via ephemeral tokens, emailed codes, or even short-lived cookies.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt;3. &lt;strong&gt;Premium API Access&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;Your AI app could also work as a micro-API:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Example endpoint: &lt;code&gt;/generate_html?desc=blue+login+form&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Free for hobbyists (limited calls/day).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Paid tier for developers who want to integrate it into their own workflows.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;em&gt;Implementation&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Host the API behind RapidAPI or Stripe-based usage credits.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Good for attracting other programmers and SaaS builders.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This option scales better than selling static templates but requires stable uptime and rate-limiting.&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;4. &lt;strong&gt;Pay-What-You-Want Donations (Enhanced)&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;While “donate” buttons are common, they can be made more compelling:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Offer a &lt;strong&gt;bonus file&lt;/strong&gt; or &lt;strong&gt;extended functionality&lt;/strong&gt; when someone donates (e.g., a premium template).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Integrate BuyMeACoffee, Ko-fi, or Stripe’s “tip jar” feature.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;em&gt;Implementation&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Minimal dev work, no data storage.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Works best if you already have traffic from open-source communities or learners.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt;5. &lt;strong&gt;Plugins &amp;amp; Marketplace Integrations&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;Instead of only offering a web tool, wrap your AI generator into a product for existing ecosystems:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;WordPress plugin&lt;/strong&gt;: “Generate CSS blocks from plain English.”&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Shopify app&lt;/strong&gt;: “AI quick theme tweaks.”&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;VS Code extension&lt;/strong&gt;: “Generate HTML snippets in editor.”&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;em&gt;Implementation&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Start with a simple downloadable plugin.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Sell it as a one-time purchase (£10–£20) on marketplaces.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This approach extends reach beyond your own site and makes revenue more stable.&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;6. &lt;strong&gt;Fiverr / Upwork Automation&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;Turn the tool into a semi-passive service:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Create a Fiverr gig: “I’ll generate a responsive HTML/CSS template with AI.”&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Behind the scenes, clients interact with your tool instead of you coding manually.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Delivery can be automated: payment → webhook → file generation → delivery.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;em&gt;Implementation&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Reuse the same code as your app, just wrap it for gig platforms.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Can generate £20–£200/month even at low traffic, depending on pricing.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt;Pricing Tips&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Low-friction pricing&lt;/strong&gt; (under £5) works best for instant purchases.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bundles&lt;/strong&gt; (£10–£30) are attractive for small business owners or students.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;For developers, &lt;strong&gt;API credits&lt;/strong&gt; are more natural (£5–£15 per 1,000 requests).&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt;Legal &amp;amp; Privacy Considerations&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Use Stripe, PayPal, or Gumroad — they handle payment security and compliance.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Keep a minimal &lt;strong&gt;privacy policy&lt;/strong&gt;: clearly state that no personal data is stored.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;For EU/UK: digital product sales may be subject to VAT — keep that in mind if scale grows.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;p&gt;AdSense may bring a trickle of revenue, but &lt;strong&gt;the real opportunity lies in direct monetization of what your AI app creates&lt;/strong&gt;. Selling small, useful digital products or offering pay-per-use access can generate anywhere from a few pounds to a few hundred pounds per month, all without user accounts or storing personal data.&lt;/p&gt;&lt;p&gt;Start simple: package one or two template bundles, add a “Buy Now” button, and deliver via expiring download links. Once you see traction, consider expanding into APIs, plugins, or marketplaces.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://i.ibb.co/PZcsKqDL/Screenshot-2025-07-18-at-07-26-45-Asky-AI-Home.png&quot; style=&quot;height:226px; width:772px&quot;&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/100/monetizing-a-asky-ai-bot</guid>
<pubDate>Wed, 17 Sep 2025 07:57:36 +0000</pubDate>
</item>
<item>
<title>Building an AI-Powered LoRa Mesh Network on Raspberry Pi 5: A Community Communication Project for Small Villages</title>
<link>https://asky.uk/99/building-powered-raspberry-community-communication-villages</link>
<description>&lt;p&gt;In remote or underserved areas, reliable communication can be a challenge due to limited internet access or infrastructure. This project outlines how to create a small-scale, decentralized communication network using Raspberry Pi 5 boards equipped with LoRa (Long Range) modules. The network is designed to support 50-100 users in a small populated place, such as a village, enabling text-based messaging, data sharing, and basic alerts without relying on cellular or Wi-Fi networks.&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://thepihut.com/cdn/shop/products/sx1268-lora-hat-for-raspberry-pi-433mhz-waveshare-wav-16804-30032679239875_800x.jpg?v=1646139975&quot; style=&quot;height:800px; width:800px&quot;&gt;&lt;br&gt;To add intelligence, we&#039;ll integrate AI capabilities on the Raspberry Pi 5 using lightweight models like TensorFlow Lite. The AI can handle tasks such as automated message routing, sentiment analysis for community alerts (e.g., detecting urgent messages), or even simple natural language processing (NLP) for chat moderation. LoRa&#039;s low-power, long-range capabilities (up to several kilometers in open areas) make it ideal for mesh networking, where devices relay messages to extend coverage.&lt;br&gt;&lt;br&gt;This setup assumes a mesh topology, where each user&#039;s device acts as a node, relaying data to others. For 50-100 users, you&#039;ll need multiple nodes, but we&#039;ll focus on building a single node prototype that can be replicated.&lt;br&gt;&lt;br&gt;&amp;nbsp;Key Benefits:&lt;br&gt;- Low cost: Each node costs around $100-150.&lt;br&gt;- Energy efficient: Suitable for solar-powered setups in off-grid areas.&lt;br&gt;- Privacy-focused: Decentralized, no central server required.&lt;br&gt;- Scalable: Easily expand by adding more nodes.&lt;br&gt;&lt;br&gt;&amp;nbsp; Estimated Range and Capacity:&amp;nbsp;&lt;br&gt;- LoRa can cover 2-10 km per hop depending on terrain and antenna.&lt;br&gt;- For 50-100 users, aim for 10-20 gateway nodes to handle traffic, with users connecting via simple LoRa-enabled devices (e.g., smartphones with LoRa adapters or dedicated handhelds).&lt;br&gt;&lt;br&gt;&amp;nbsp; Required Components&lt;br&gt;&lt;br&gt;For a single node (Raspberry Pi 5 as a gateway/router):&lt;br&gt;- Raspberry Pi 5 (4GB or 8GB model recommended for AI tasks).&lt;br&gt;- LoRa module: SX1276/SX1278-based HAT or breakout board (e.g., Dragino LoRa HAT or Waveshare SX1262).&lt;br&gt;- Antenna: High-gain outdoor antenna (5-9 dBi) for better range.&lt;br&gt;- Power supply: 5V/3A USB-C adapter; consider solar panels for remote deployment.&lt;br&gt;- Storage: 16GB+ microSD card with Raspberry Pi OS (Lite version for efficiency).&lt;br&gt;- Display/Keyboard (optional for setup): HDMI monitor and USB peripherals.&lt;br&gt;- Enclosure: Weatherproof case for outdoor use.&lt;br&gt;- Additional for AI: USB accelerator like Coral TPU (optional for faster inference).&lt;br&gt;&lt;br&gt;For user endpoints (simpler nodes):&lt;br&gt;- ESP32 or Arduino boards with LoRa modules (cheaper alternatives to full Pi setups for end-users).&lt;br&gt;- Mobile app integration: Use Bluetooth to connect smartphones to LoRa nodes.&lt;br&gt;&lt;br&gt;Total cost per gateway node: ~$120. Scale up by distributing simpler nodes to users.&lt;br&gt;&lt;br&gt;&amp;nbsp;Step-by-Step Instructions&lt;br&gt;&lt;br&gt;&amp;nbsp;Step 1: Hardware Assembly&lt;br&gt;1.&amp;nbsp; &amp;nbsp;Set up the Raspberry Pi 5:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp;- Insert the microSD card with Raspberry Pi OS installed (download from raspberrypi.com and flash using Raspberry Pi Imager).&lt;br&gt;&amp;nbsp; &amp;nbsp;- Connect the LoRa HAT/module to the Pi&#039;s GPIO pins. For Dragino HAT, align pins and secure.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Attach the antenna to the LoRa module&#039;s connector.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Power on the Pi and boot into the OS.&lt;br&gt;&lt;br&gt;2.&amp;nbsp; &amp;nbsp;Test Connections:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp;- SSH into the Pi (enable SSH in raspi-config).&lt;br&gt;&amp;nbsp; &amp;nbsp;- Verify LoRa module: Run `ls /dev` to check for `/dev/spidev0.0` (SPI interface).&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;Step 2: Software Installation&lt;br&gt;1.&amp;nbsp; &amp;nbsp;Update System:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y&lt;br&gt;&amp;nbsp; &amp;nbsp;sudo apt install python3-pip git -y&lt;br&gt;&amp;nbsp; &amp;nbsp;```&lt;br&gt;&lt;br&gt;2.&amp;nbsp; Install LoRa Libraries:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp;- Use PyLoRa or LoRaWAN libraries. Clone a mesh networking library like Meshtastic (which supports LoRa for chat networks).&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;git clone https://github.com/meshtastic/Meshtastic-python.git&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;cd Meshtastic-python&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;pip3 install -r requirements.txt&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp;- Alternatively, for custom setup: Install `RPi.GPIO` and `spidev`.&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;pip3 install RPi.GPIO spidev&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&lt;br&gt;3.&amp;nbsp; &amp;nbsp;Install AI Frameworks:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp;- TensorFlow Lite for edge AI:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;sudo apt install libatlas-base-dev -y&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;pip3 install tensorflow-lite&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp;- For NLP/sentiment analysis, add Hugging Face&#039;s Transformers (lite version):&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;pip3 install transformers torch&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp;- Download a pre-trained model, e.g., DistilBERT for sentiment:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;from transformers import pipeline&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;classifier = pipeline(&#039;sentiment-analysis&#039;)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Step 3: Configure LoRa Mesh Network&lt;br&gt;1.&amp;nbsp; &amp;nbsp;Set Up LoRa Parameters:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp;- Frequency: Use 433MHz, 868MHz, or 915MHz based on your region&#039;s regulations (check local laws).&lt;br&gt;&amp;nbsp; &amp;nbsp;- In code, configure spreading factor (SF7-SF12) for range vs. speed trade-off. Higher SF for longer range but slower data.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Example Python script for basic send/receive:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```python&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import time&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import LoRa&amp;nbsp; # Assuming PyLoRa library&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;lora = LoRa.LoRa(verbose=False)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;lora.set_mode(LoRa.MODE.STDBY)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;lora.set_freq(915.0)&amp;nbsp; # Adjust frequency&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;lora.set_spreading_factor(7)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# Send message&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;lora.write_payload([ord(c) for c in &quot;Hello LoRa!&quot;])&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;lora.set_mode(LoRa.MODE.TX)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;time.sleep(1)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# Receive loop&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while True:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if lora.received_packet():&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;payload = lora.read_payload()&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print(&quot;&quot;.join(chr(b) for b in payload))&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&lt;br&gt;2.&amp;nbsp; &amp;nbsp;Implement Mesh Topology:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp;- Use libraries like PainlessMesh or adapt Meshtastic for LoRa.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Each node broadcasts its ID and relays messages if not the destination.&lt;br&gt;&amp;nbsp; &amp;nbsp;- For 50-100 users: Limit hops to 3-5 to avoid latency. Use channel hopping to reduce interference.&lt;br&gt;&lt;br&gt;3.&amp;nbsp; &amp;nbsp;Integrate AI:&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;- Message Routing with AI: Use a simple ML model to predict optimal routes based on signal strength history.&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;- Collect data: Log RSSI (Received Signal Strength Indicator) from LoRa packets.&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;- Train a basic model (e.g., scikit-learn on Pi):&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pip3 install scikit-learn&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Example: Linear regression for path prediction.&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;- Sentiment Analysis for Alerts: Analyze incoming messages.&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```python&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;from transformers import pipeline&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;classifier = pipeline(&#039;sentiment-analysis&#039;, model=&#039;distilbert-base-uncased-finetuned-sst-2-english&#039;)&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;def analyze_message(msg):&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;result = classifier(msg)[0]&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if result[&#039;label&#039;] == &#039;NEGATIVE&#039; and result[&#039;score&#039;] &amp;gt; 0.8:&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return &quot;Alert: Potential emergency!&quot;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return &quot;Normal message&quot;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# Integrate into receive loop&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;msg = &quot;&quot;.join(chr(b) for b in payload)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;print(analyze_message(msg))&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp;- NLP for Moderation: Filter spam or translate messages using lightweight models.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Run AI on boot: Use systemd service to start scripts.&lt;br&gt;&lt;br&gt;### Step 4: User Interface and Deployment&lt;br&gt;1. Build a Simple App:&lt;br&gt;&amp;nbsp; &amp;nbsp;- Web-based UI: Use Flask on Pi.&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;pip3 install flask&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;```&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Create a dashboard for sending/receiving messages.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Mobile Integration: Pair with Bluetooth for smartphone access (use BlueZ on Pi).&lt;br&gt;&amp;nbsp; &amp;nbsp;- For end-users: Distribute ESP32-LoRa kits with a simple LCD/button interface.&lt;br&gt;&lt;br&gt;2.&amp;nbsp; &amp;nbsp;Network Deployment:&lt;br&gt;&amp;nbsp; &amp;nbsp;- Place gateway Pis on high points (roofs, hills) for coverage.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Test range: Start with 2-3 nodes, send messages, measure latency.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Scale: Assign unique IDs to users. Use encryption (e.g., AES via pycryptodome) for privacy.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Power Management: Enable sleep modes on LoRa for battery life.&lt;br&gt;&lt;br&gt;3.&amp;nbsp; &amp;nbsp;Testing and Optimization:&lt;br&gt;&amp;nbsp; &amp;nbsp;- Simulate 50-100 users: Use multiple virtual nodes or scripts to flood messages.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Monitor with AI: Implement anomaly detection to flag network issues.&lt;br&gt;&amp;nbsp; &amp;nbsp;- Bandwidth: LoRa is low-data ( ~0.3-50 kbps), so limit to text/short data.&lt;br&gt;&lt;br&gt;&amp;nbsp; Challenges and Considerations&lt;br&gt;- Regulatory Compliance: Ensure LoRa frequency use is legal in your area (e.g., FCC in US, ETSI in Europe).&lt;br&gt;- Security:Add authentication to prevent unauthorized access.&lt;br&gt;- Scalability Limits: For &amp;gt;100 users, consider hybrid with Wi-Fi gateways.&lt;br&gt;- AI Performance: Raspberry Pi 5&#039;s NPU helps, but heavy models may need optimization or offloading.&lt;br&gt;- Maintenance:Remote SSH for updates; use Watchdog for reliability.&lt;br&gt;&lt;br&gt;&amp;nbsp;Conclusion&lt;br&gt;This AI-enhanced LoRa mesh network on Raspberry Pi 5 empowers small communities with resilient communication. By following these steps, you can prototype a node in a weekend and deploy a full network in weeks. Experiment, iterate, and share your improvements—open-source the code on GitHub for community benefit!&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/99/building-powered-raspberry-community-communication-villages</guid>
<pubDate>Sun, 07 Sep 2025 11:52:53 +0000</pubDate>
</item>
<item>
<title>Turn Your Raspberry Pi into a Chat-with-PDF AI Assistant</title>
<link>https://asky.uk/98/turn-your-raspberry-pi-into-a-chat-with-pdf-ai-assistant</link>
<description>&lt;hr&gt;&lt;h1&gt; Turn Your Raspberry Pi into a Chat-with-PDF AI Assistant&lt;/h1&gt;&lt;div&gt;&lt;img alt=&quot;&quot; src=&quot;https://www.pdfgear.com/how-to/img/best-ai-to-chat-with-any-pdf-1.png&quot; style=&quot;height:540px; width:900px&quot;&gt;&lt;/div&gt;&lt;p&gt;The Raspberry Pi 5 is powerful enough to handle some surprisingly advanced AI tasks. Today, we’ll show you how to build a &lt;strong&gt;Chat-with-PDF Assistant&lt;/strong&gt; on your Pi — a local tool that lets you upload PDF files and ask questions about them using natural language, just like ChatGPT.&lt;/p&gt;&lt;p&gt;No need for the cloud. Everything runs &lt;strong&gt;locally&lt;/strong&gt; on your Raspberry Pi.&lt;/p&gt;&lt;hr&gt;&lt;h2&gt; What You’ll Build&lt;/h2&gt;&lt;p&gt;A local AI assistant that can:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Ingest PDF files&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Convert text to vector embeddings&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Accept questions in plain English&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Answer based on PDF contents&lt;br&gt;All without sending your documents to the cloud.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt; What You’ll Need&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Raspberry Pi 5&lt;/strong&gt; (or Pi 4 with swap enabled)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;64-bit Raspberry Pi OS&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Python 3.9+&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;pip&lt;/strong&gt; and &lt;strong&gt;virtualenv&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;PDF document(s)&lt;/strong&gt; to test with&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Internet connection (initial setup only)&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt; Step 1: Install Required Packages&lt;/h2&gt;&lt;p&gt;First, update your Pi and install basic dependencies:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install python3-pip python3-venv
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Create and activate a virtual environment:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python3 -m venv pdfbot-env
source pdfbot-env/bin/activate
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now install the core Python libraries:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install --upgrade pip
pip install langchain faiss-cpu pypdf openai tiktoken
&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;&lt;p&gt;Optionally:&lt;br&gt;Replace &lt;code&gt;openai&lt;/code&gt; with &lt;code&gt;llama-cpp-python&lt;/code&gt; or &lt;code&gt;transformers&lt;/code&gt; if you want to use local models instead of OpenAI’s API.&lt;/p&gt;&lt;/blockquote&gt;&lt;hr&gt;&lt;h2&gt; Step 2: Load and Split Your PDF&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain.document_loaders import PyPDFLoader
from langchain.text_splitter import CharacterTextSplitter

loader = PyPDFLoader(&quot;your_file.pdf&quot;)
pages = loader.load()

text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
documents = text_splitter.split_documents(pages)
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt; Step 3: Embed and Store Text&lt;/h2&gt;&lt;p&gt;Use FAISS to store searchable vectors:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain.vectorstores import FAISS
from langchain.embeddings.openai import OpenAIEmbeddings

embedding = OpenAIEmbeddings()
db = FAISS.from_documents(documents, embedding)
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt; Step 4: Set Up the Chat Function&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from langchain.chains.question_answering import load_qa_chain
from langchain.llms import OpenAI

chain = load_qa_chain(OpenAI(), chain_type=&quot;stuff&quot;)

def ask(query):
    docs = db.similarity_search(query)
    answer = chain.run(input_documents=docs, question=query)
    return answer
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Example usage:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;print(ask(&quot;What does the report say about revenue growth in 2023?&quot;))
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt;️ Optional: Use a Local Model Instead of OpenAI&lt;/h2&gt;&lt;p&gt;Replace &lt;code&gt;OpenAI()&lt;/code&gt; with a local LLM like &lt;code&gt;llama.cpp&lt;/code&gt;, or use an API like Ollama running on your Pi. Just swap out the &lt;code&gt;LLM&lt;/code&gt; in &lt;code&gt;load_qa_chain&lt;/code&gt;.&lt;/p&gt;&lt;hr&gt;&lt;h2&gt; Final Notes&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi 5 handles vector search + API queries easily.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;RAM-intensive operations like LLM inference locally may require &lt;strong&gt;swap files&lt;/strong&gt; or &lt;strong&gt;8GB model variants&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;For full local use, combine with &lt;code&gt;llama.cpp&lt;/code&gt; and a local embedding model.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt; Summary&lt;/h2&gt;&lt;p&gt;You’ve now built a Chat-with-PDF Assistant that runs on your Raspberry Pi and can answer questions about any document you upload. It&#039;s private, fast, and extendable.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/98/turn-your-raspberry-pi-into-a-chat-with-pdf-ai-assistant</guid>
<pubDate>Tue, 22 Jul 2025 06:47:24 +0000</pubDate>
</item>
<item>
<title>Run a Stable Diffusion Image Generator Locally on Raspberry Pi 5</title>
<link>https://asky.uk/97/run-stable-diffusion-image-generator-locally-on-raspberry</link>
<description>&lt;h2&gt;&lt;strong&gt;Run a Stable Diffusion Image Generator Locally on Raspberry Pi 5&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://miro.medium.com/v2/resize:fit:1200/1*Rbq9cDCJpGq7HKeNAeIitg.jpeg&quot; style=&quot;height:506px; width:900px&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Create stunning AI-generated images on your Pi — without internet!&lt;/em&gt;&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;️ Overview&lt;/h3&gt;&lt;p&gt;Stable Diffusion is a powerful open-source image generation model that turns &lt;strong&gt;text prompts&lt;/strong&gt; into &lt;strong&gt;photorealistic or artistic images&lt;/strong&gt;. While it&#039;s typically run on desktops with powerful GPUs, recent optimizations and the Raspberry Pi 5&#039;s performance improvements make it possible (with compromises) to run &lt;strong&gt;lightweight versions&lt;/strong&gt; of it &lt;strong&gt;locally&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;In this article, we’ll show you how to:&lt;/p&gt;&lt;p&gt;✅ Run a CPU-friendly version of Stable Diffusion on Raspberry Pi 5&lt;br&gt;✅ Generate images from text prompts&lt;br&gt;✅ Use Python and diffusers library from HuggingFace&lt;br&gt;✅ Work fully offline after setup&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;⚠️ &lt;em&gt;This guide uses a highly optimized model suited for CPU-only inference. Don’t expect real-time speed — but it works!&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;hr&gt;&lt;h3&gt;Requirements&lt;/h3&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Component&lt;/th&gt;&lt;th&gt;Version / Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Raspberry Pi&lt;/td&gt;&lt;td&gt;Pi 5 (8GB RAM strongly recommended)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;OS&lt;/td&gt;&lt;td&gt;Raspberry Pi OS Bookworm (64-bit)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Python&lt;/td&gt;&lt;td&gt;≥ 3.10&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Disk Space&lt;/td&gt;&lt;td&gt;~6 GB&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Internet&lt;/td&gt;&lt;td&gt;Only for installation and model download&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Model&lt;/td&gt;&lt;td&gt;Stable Diffusion 1.5 (CPU-optimized)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;hr&gt;&lt;h3&gt;Step 1: System Setup&lt;/h3&gt;&lt;pre&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install python3 python3-venv python3-pip -y
&lt;/pre&gt;&lt;p&gt;Create and activate a Python virtual environment:&lt;/p&gt;&lt;pre&gt;python3 -m venv sd-env
source sd-env/bin/activate
&lt;/pre&gt;&lt;hr&gt;&lt;h3&gt;Step 2: Install Required Python Libraries&lt;/h3&gt;&lt;pre&gt;pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install diffusers transformers accelerate scipy safetensors
&lt;/pre&gt;&lt;p&gt;We use the &lt;strong&gt;CPU-only version of PyTorch&lt;/strong&gt; to ensure compatibility with the Raspberry Pi’s hardware.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Step 3: Download a CPU-optimized Model&lt;/h3&gt;&lt;p&gt;Let’s use the runwayml/stable-diffusion-v1-5 or smaller variant from HuggingFace.&lt;/p&gt;&lt;p&gt;You can use this script to automatically load and save the model locally:&lt;/p&gt;&lt;pre&gt;from diffusers import StableDiffusionPipeline
import torch

pipeline = StableDiffusionPipeline.from_pretrained(
    &quot;runwayml/stable-diffusion-v1-5&quot;,
    torch_dtype=torch.float32,
)
pipeline = pipeline.to(&quot;cpu&quot;)

prompt = &quot;A cyberpunk robot cat, neon background&quot;
image = pipeline(prompt).images[0]
image.save(&quot;output.png&quot;)
&lt;/pre&gt;&lt;hr&gt;&lt;h3&gt;Tip: Use Smaller Models&lt;/h3&gt;&lt;p&gt;If your Pi struggles, try:&lt;/p&gt;&lt;pre&gt;from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(&quot;stabilityai/stable-diffusion-2-1-base&quot;)
&lt;/pre&gt;&lt;p&gt;Or explore CPU-optimized models like:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;CompVis/stable-diffusion-v1-4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Linaqruf/stable-diffusion-1-5-better-vae&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;SG161222/Realistic_Vision_V5.1_noVAE&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h3&gt;How Long Does It Take?&lt;/h3&gt;&lt;p&gt;On Raspberry Pi 5 (8GB):&lt;/p&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Image Size&lt;/th&gt;&lt;th&gt;Inference Time&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;256x256&lt;/td&gt;&lt;td&gt;~2-4 minutes&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;512x512&lt;/td&gt;&lt;td&gt;~7-12 minutes&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;⚠️ Do &lt;strong&gt;not&lt;/strong&gt; expect desktop GPU speeds — but for low-volume, offline creative projects, it&#039;s functional.&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Optional: Serve as a Web App with Gradio&lt;/h3&gt;&lt;pre&gt;pip install gradio
&lt;/pre&gt;&lt;p&gt;Add this to the script:&lt;/p&gt;&lt;pre&gt;import gradio as gr

def generate(prompt):
    image = pipeline(prompt).images[0]
    return image

gr.Interface(fn=generate, inputs=&quot;text&quot;, outputs=&quot;image&quot;).launch()
&lt;/pre&gt;&lt;p&gt;Access locally via http://localhost:7860&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Example Output&lt;/h3&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Prompt&lt;/th&gt;&lt;th&gt;Result&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;“A medieval knight riding a dragon through the clouds”&lt;/em&gt;&lt;/td&gt;&lt;td&gt;️ &lt;img alt=&quot;Example&quot; src=&quot;#&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;“A serene lake in the forest during sunset, ultra-realistic”&lt;/em&gt;&lt;/td&gt;&lt;td&gt;️ &lt;img alt=&quot;Example&quot; src=&quot;#&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;em&gt;(You can host real examples or dummy images later on your blog)&lt;/em&gt;&lt;/p&gt;&lt;hr&gt;&lt;h3&gt;Summary&lt;/h3&gt;&lt;p&gt;You’ve now turned your Raspberry Pi 5 into a &lt;strong&gt;local AI image generator&lt;/strong&gt; using Stable Diffusion. While it’s not lightning-fast, it’s fully offline, works with open-source tools, and gives you creative freedom at the edge.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/97/run-stable-diffusion-image-generator-locally-on-raspberry</guid>
<pubDate>Sun, 20 Jul 2025 18:58:24 +0000</pubDate>
</item>
<item>
<title>Image Caption Generator using BLIP + PiCamera on Raspberry Pi</title>
<link>https://asky.uk/96/image-caption-generator-using-blip-picamera-on-raspberry-pi</link>
<description>&lt;h1&gt;️ Image Caption Generator using BLIP + PiCamera on Raspberry Pi&lt;/h1&gt;&lt;div&gt;&lt;img alt=&quot;&quot; src=&quot;https://miro.medium.com/v2/resize:fit:1400/0*WeUeBnvELPwBQ7ff&quot; style=&quot;height:238px; width:900px&quot;&gt;&lt;/div&gt;&lt;p&gt;Turn your Raspberry Pi into a smart image captioning device using BLIP, an AI model that generates natural language descriptions of images.&lt;/p&gt;&lt;hr&gt;&lt;h2&gt; Overview&lt;/h2&gt;&lt;p&gt;In this project, you will:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Capture images using the PiCamera&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Use the BLIP (Bootstrapped Language Image Pretraining) model to generate captions&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Display or store the generated captions&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Optionally build a simple web interface with Gradio&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This project works best with Raspberry Pi 4 or 5 and requires an internet connection (for downloading models or using APIs).&lt;/p&gt;&lt;hr&gt;&lt;h2&gt; Requirements&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi 4 or 5 (Pi 3 will struggle with BLIP model inference)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi OS 64-bit (updated)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;PiCamera or USB camera&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Python 3.9+&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;pip and virtualenv&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Git&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt; Step 1: Install System Dependencies&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install python3-pip python3-venv libjpeg-dev libopenjp2-7-dev
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt; Step 2: Set Up Python Environment&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;mkdir ~/blip-caption
cd ~/blip-caption
python3 -m venv venv
source venv/bin/activate
pip install torch torchvision
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt; Step 3: Install HuggingFace Transformers and BLIP&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install transformers timm pillow
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt; Step 4: Capture Image with PiCamera&lt;/h2&gt;&lt;p&gt;If you&#039;re using the legacy PiCamera:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install picamera
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And use this code to capture an image:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from picamera import PiCamera
from time import sleep

camera = PiCamera()
camera.start_preview()
sleep(2)
camera.capture(&#039;image.jpg&#039;)
camera.stop_preview()
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For USB camera, use OpenCV:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install opencv-python
&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import cv2
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
cv2.imwrite(&#039;image.jpg&#039;, frame)
cap.release()
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt; Step 5: Generate Caption Using BLIP&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from transformers import BlipProcessor, BlipForConditionalGeneration
from PIL import Image
import torch

processor = BlipProcessor.from_pretrained(&quot;Salesforce/blip-image-captioning-base&quot;)
model = BlipForConditionalGeneration.from_pretrained(&quot;Salesforce/blip-image-captioning-base&quot;)

raw_image = Image.open(&quot;image.jpg&quot;).convert(&#039;RGB&#039;)
inputs = processor(raw_image, return_tensors=&quot;pt&quot;)
out = model.generate(**inputs)
caption = processor.decode(out[0], skip_special_tokens=True)
print(&quot;Caption:&quot;, caption)
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt; Optional: Add Gradio Interface&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install gradio
&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import gradio as gr

def caption_image(image):
    inputs = processor(image, return_tensors=&quot;pt&quot;)
    out = model.generate(**inputs)
    return processor.decode(out[0], skip_special_tokens=True)

gr.Interface(fn=caption_image, inputs=&quot;image&quot;, outputs=&quot;text&quot;).launch()
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt;✅ Conclusion&lt;/h2&gt;&lt;p&gt;You&#039;ve built a working image caption generator using Raspberry Pi, PiCamera, and the BLIP AI model. You can now:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Add automatic uploads or email integration&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Extend it into a surveillance or accessibility tool&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Use it in photo archiving projects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/96/image-caption-generator-using-blip-picamera-on-raspberry-pi</guid>
<pubDate>Sun, 20 Jul 2025 11:21:30 +0000</pubDate>
</item>
<item>
<title>Build an AI Resume / CV Generator on Raspberry Pi</title>
<link>https://asky.uk/94/build-an-ai-resume-cv-generator-on-raspberry-pi</link>
<description>&lt;p&gt;One of the most requested AI tools today is an automatic CV or Resume Generator powered by language models. In this guide, we&#039;ll show you how to build one on a Raspberry Pi 4 using Python and Open Source models. This lightweight solution doesn&#039;t require paid API keys, and it can be deployed as a local or web-based app.&lt;/p&gt;&lt;h2&gt;Requirements&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi 4 (4GB or 8GB RAM recommended)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Raspberry Pi OS (Bookworm or Bullseye)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Python 3.9+&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;pip (Python package manager)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Basic knowledge of Python and command line&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;(Optional) Flask or Gradio for Web Interface&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Step 1: Update and Prepare Your Pi&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install python3-pip git
&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;Step 2: Create Project Directory&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;mkdir ~/cv_generator &amp;amp;&amp;amp; cd ~/cv_generator
python3 -m venv venv
source venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;Step 3: Install Required Libraries&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install transformers gradio torch
&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;&lt;p&gt;On Raspberry Pi 4, Torch may take a while to install. Use &lt;code&gt;pip install torch==1.13.1&lt;/code&gt; if you face version issues.&lt;/p&gt;&lt;/blockquote&gt;&lt;h2&gt;Step 4: Choose a Small Language Model&lt;/h2&gt;&lt;p&gt;We&#039;ll use the lightweight &lt;a rel=&quot;nofollow&quot; href=&quot;https://huggingface.co/distilgpt2&quot;&gt;distilGPT2&lt;/a&gt; to generate CV content.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from transformers import pipeline

generator = pipeline(&quot;text-generation&quot;, model=&quot;distilgpt2&quot;)

def generate_cv(name, job_title):
    prompt = f&quot;Create a professional resume for {name}, applying for a {job_title} position.&quot;
    result = generator(prompt, max_length=300, num_return_sequences=1)
    return result[0][&#039;generated_text&#039;]
&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;Step 5: Add Gradio Interface&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import gradio as gr

def run_cv_gen(name, job):
    return generate_cv(name, job)

gr.Interface(fn=run_cv_gen,
             inputs=[&quot;text&quot;, &quot;text&quot;],
             outputs=&quot;text&quot;,
             title=&quot;AI CV Generator on Pi&quot;,
             description=&quot;Enter your name and job title to generate a sample CV.&quot;).launch()
&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;Step 6: Run the App&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python3 app.py
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Open your browser at &lt;code&gt;http://localhost:7860&lt;/code&gt;&lt;/p&gt;&lt;h2&gt;Step 7: Optional - Make It Public&lt;/h2&gt;&lt;p&gt;Use &lt;a rel=&quot;nofollow&quot; href=&quot;https://ngrok.com&quot;&gt;ngrok&lt;/a&gt; or &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.npmjs.com/package/localtunnel&quot;&gt;localtunnel&lt;/a&gt; to share your local Pi app with the world.&lt;/p&gt;&lt;p&gt;Example with localtunnel:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npx localtunnel --port 7860
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt;Final Tips&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;You can replace &lt;code&gt;distilgpt2&lt;/code&gt; with any other small language model for more detailed results.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Add a &quot;Download as PDF&quot; button using &lt;code&gt;pdfkit&lt;/code&gt; or &lt;code&gt;reportlab&lt;/code&gt; for resume export.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Consider adding language selection for multi-lingual CVs.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Future Enhancements&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Add support for uploading an existing resume and improving it&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Integrate with job boards or LinkedIn scraping&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Add image/logo or AI-generated portrait with Stable Diffusion&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://careercompanion.cv-creator.com/theme/Cakestrap/img/logo.jpg&quot; style=&quot;height:158px; width:297px&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/94/build-an-ai-resume-cv-generator-on-raspberry-pi</guid>
<pubDate>Sat, 19 Jul 2025 19:59:30 +0000</pubDate>
</item>
<item>
<title>Run Whisper Speech-to-Text on Raspberry Pi 5</title>
<link>https://asky.uk/93/run-whisper-speech-to-text-on-raspberry-pi-5</link>
<description>&lt;h1&gt;How to Run Whisper AI Speech-to-Text on Raspberry Pi 5 (Offline)&lt;/h1&gt;&lt;p&gt;&lt;strong&gt;Contents:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;✅ What is Whisper?&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;✅ How it works on Raspberry Pi 5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;✅ Step-by-step installation&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;✅ Record your voice&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;✅ Transcribe with Whisper&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;✅ Optimization tips&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;✅ Test result&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt;What is Whisper?&lt;/h2&gt;&lt;p&gt;Whisper is a powerful &lt;strong&gt;AI model for converting speech to text&lt;/strong&gt;, created by OpenAI. It supports over 90 languages and can work &lt;strong&gt;entirely offline&lt;/strong&gt; thanks to &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/ggerganov/whisper.cpp&quot;&gt;whisper.cpp&lt;/a&gt; – a C/C++ port of the original model optimized for low-resource devices like Raspberry Pi.&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://nolongerset.com/content/images/2025/04/ultra_realistic_im_image.jpg&quot; style=&quot;height:547px; width:980px&quot;&gt;&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;Requirements&lt;/h2&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Component&lt;/th&gt;&lt;th&gt;Recommended&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Raspberry Pi 5&lt;/td&gt;&lt;td&gt;4GB or 8GB RAM ✅&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Microphone&lt;/td&gt;&lt;td&gt;USB or 3.5mm Jack&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;OS&lt;/td&gt;&lt;td&gt;Raspberry Pi OS 64-bit&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Internet&lt;/td&gt;&lt;td&gt;Only during installation&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;hr&gt;&lt;h2&gt;Step 1: Install Dependencies&lt;/h2&gt;&lt;pre&gt;sudo apt update
sudo apt install git build-essential cmake python3-pip portaudio19-dev ffmpeg -y
&lt;/pre&gt;&lt;p&gt;Clone and build whisper.cpp:&lt;/p&gt;&lt;pre&gt;git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp
make
&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt;Step 2: Download the tiny.en model (~75MB)&lt;/h2&gt;&lt;pre&gt;./models/download-ggml-model.sh tiny.en
&lt;/pre&gt;&lt;blockquote&gt;&lt;p&gt;This is the &lt;strong&gt;fastest&lt;/strong&gt; and most suitable model for Raspberry Pi 5.&lt;/p&gt;&lt;/blockquote&gt;&lt;hr&gt;&lt;h2&gt;️ Step 3: Record 10 seconds of audio&lt;/h2&gt;&lt;p&gt;Use arecord:&lt;/p&gt;&lt;pre&gt;arecord -D plughw:1,0 -f cd -t wav -d 10 -r 16000 test.wav
&lt;/pre&gt;&lt;p&gt;To find your device name:&lt;/p&gt;&lt;pre&gt;arecord -l
&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt;Step 4: Transcribe the audio with Whisper&lt;/h2&gt;&lt;pre&gt;./main -m models/ggml-tiny.en.bin -f test.wav -otxt
&lt;/pre&gt;&lt;p&gt;This will produce test.wav.txt containing the recognized speech.&lt;/p&gt;&lt;hr&gt;&lt;h2&gt;Tips for Better Performance&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Always use &lt;strong&gt;tiny.en&lt;/strong&gt; model for speed&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Disable GUI / run in CLI mode (raspi-config → Boot to CLI)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Use class 10 U3 microSD or USB SSD for better I/O&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr&gt;&lt;h2&gt;Example Result&lt;/h2&gt;&lt;pre&gt;[00:00:00.000 --&amp;gt; 00:00:05.000] Hello, this is a test of the Whisper AI on Raspberry Pi 5.
&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt;Support the Project&lt;/h2&gt;&lt;pre&gt;&amp;lt;a href=&quot;https://ko-fi.com/askyai&quot; target=&quot;_blank&quot;&amp;gt;
  ☕ Support this tutorial on Ko-fi
&amp;lt;/a&amp;gt;
&lt;/pre&gt;&lt;hr&gt;&lt;h2&gt;Share This Guide&lt;/h2&gt;&lt;h2&gt;✅ You&#039;re Ready!&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>AI + Rasberry PI</category>
<guid isPermaLink="true">https://asky.uk/93/run-whisper-speech-to-text-on-raspberry-pi-5</guid>
<pubDate>Sat, 19 Jul 2025 14:54:30 +0000</pubDate>
</item>
</channel>
</rss>