Hledám programátora pro jednorázový projekt
Napsal: 30 led 2025, 04:22
Ahoj, potrebuju programatora na Arduino, arduino uno.
Prosim psat na smartmaster@seznam.cz
Prosim psat na smartmaster@seznam.cz
České fórum pro všechny nadšence do Arduina a dalších technologií.
https://forum.hwkitchen.cz/
Kód: Vybrat vše
# Import necessary libraries
import cv2
from ultralytics import YOLO
# Initialize the YOLO model
# We'll use YOLOv8n (nano) for better performance on Raspberry Pi
model = YOLO('yolov8n.pt') # Downloads the model automatically
# Define the target class
# COCO dataset class for 'cat' is usually class 15
TARGET_CLASS = 'cat'
# Initialize video capture
# 0 is usually the default camera. Change if you have multiple cameras.
cap = cv2.VideoCapture(0)
# Function to get class names
def get_class_names():
# Load COCO class names
return model.names
class_names = get_class_names()
# Verify if 'cat' is in the class names
if TARGET_CLASS not in class_names:
print(f"'{TARGET_CLASS}' class not found in the model's classes.")
exit()
# Get the index of the 'cat' class
cat_class_id = list(class_names).index(TARGET_CLASS)
# Initialize variables to store bounding box info
cat_bbox = ()
cat_size = 0
while True:
# Read a frame from the camera
ret, frame = cap.read()
if not ret:
print("Failed to grab frame")
break
# Perform object detection
results = model(frame)
# Parse results
for result in results:
boxes = result.boxes # Bounding boxes
for box in boxes:
cls_id = int(box.cls[0]) # Class ID
if cls_id == cat_class_id:
# Get bounding box coordinates
x1, y1, x2, y2 = box.xyxy[0]
# Calculate width and height
width = x2 - x1
height = y2 - y1
# Store the coordinates and size
cat_bbox = (int(x1), int(y1), int(x2), int(y2))
cat_size = (int(width), int(height))
# Draw bounding box on the frame (optional)
cv2.rectangle(frame, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2)
cv2.putText(frame, f'Cat: {width}x{height}', (int(x1), int(y1)-10),
cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
# Since we only need to detect one cat, break after finding it
break
# Display the frame (optional)
cv2.imshow('Cat Detector', frame)
# Exit on pressing 'q'
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release resources
cap.release()
cv2.destroyAllWindows()
# Print the bounding box and size
if cat_bbox:
print(f"Cat Bounding Box Coordinates: {cat_bbox}")
print(f"Cat Size (Width x Height): {cat_size}")
else:
print("No cat detected.")
Dekuju. Ano, chápu, že potřebuji Raspberry Pi. Camer + Arduino Uno + PC nebo Raspberry. Protože jsem konstrukter, ne programátor potrebuju pomoc s programou. Platim za pomoc 5000 Kc. Ale to je castka vcetne debugovani.
Good jobCaster píše: ↑31 led 2025, 11:13Zrovna pracuji na něčem podobném, laserová hračka pro kočku. Program jsem předělal pro ATtiny202 a v pohodě funguje, kočka Kačka ráda běhá za světýlkem na koberci.
Brácha si ale stěžoval, že laser občas svítí na kočku. Převedl jsem proto program do Pythonu pro RPi4 a pomocí rozpoznání kočky ve videu (docker ultralytics yolo 8/11 vypnu laser, případně vygeneruji jiný bod, pokud by měl na ni laser svítit.
Pro rychlé zpracování signálu videa zvažuji koupit Jetson Orin Nano Super Developer Kit.
Od detekce kočky v obraze je to jen malý krůček k detekci člověka.
Kód: Vybrat vše
# Import necessary libraries import cv2 from ultralytics import YOLO # Initialize the YOLO model # We'll use YOLOv8n (nano) for better performance on Raspberry Pi model = YOLO('yolov8n.pt') # Downloads the model automatically # Define the target class # COCO dataset class for 'cat' is usually class 15 TARGET_CLASS = 'cat' # Initialize video capture # 0 is usually the default camera. Change if you have multiple cameras. cap = cv2.VideoCapture(0) # Function to get class names def get_class_names(): # Load COCO class names return model.names class_names = get_class_names() # Verify if 'cat' is in the class names if TARGET_CLASS not in class_names: print(f"'{TARGET_CLASS}' class not found in the model's classes.") exit() # Get the index of the 'cat' class cat_class_id = list(class_names).index(TARGET_CLASS) # Initialize variables to store bounding box info cat_bbox = () cat_size = 0 while True: # Read a frame from the camera ret, frame = cap.read() if not ret: print("Failed to grab frame") break # Perform object detection results = model(frame) # Parse results for result in results: boxes = result.boxes # Bounding boxes for box in boxes: cls_id = int(box.cls[0]) # Class ID if cls_id == cat_class_id: # Get bounding box coordinates x1, y1, x2, y2 = box.xyxy[0] # Calculate width and height width = x2 - x1 height = y2 - y1 # Store the coordinates and size cat_bbox = (int(x1), int(y1), int(x2), int(y2)) cat_size = (int(width), int(height)) # Draw bounding box on the frame (optional) cv2.rectangle(frame, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2) cv2.putText(frame, f'Cat: {width}x{height}', (int(x1), int(y1)-10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2) # Since we only need to detect one cat, break after finding it break # Display the frame (optional) cv2.imshow('Cat Detector', frame) # Exit on pressing 'q' if cv2.waitKey(1) & 0xFF == ord('q'): break # Release resources cap.release() cv2.destroyAllWindows() # Print the bounding box and size if cat_bbox: print(f"Cat Bounding Box Coordinates: {cat_bbox}") print(f"Cat Size (Width x Height): {cat_size}") else: print("No cat detected.")
Ano, dekuju. Ale pro me lepe mit programatora ) Ze on objednal co potrebujetPablo74 píše: ↑31 led 2025, 09:20Jak už zmínil Diego, tohle bude vyžadovat výkonnější HW; buď to zmíněný Raspberry Pi nebo ESP32, samozřejmě s kamerou, např. https://www.laskakit.cz/esp32-cam-2-4gh ... ex-antena/