Skip to content

Commit

Permalink
whitespaces linting
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaisteMotiejunaite committed Oct 22, 2024
1 parent 61f999a commit c7812e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Algorithms/Body/HandGestures.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def recognize_gesture(landmarks):

# Convert the frame to RGB format for MediaPipe
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

# Process the frame and get hand landmarks
results = hands.process(frame_rgb)

Expand All @@ -122,7 +122,7 @@ def recognize_gesture(landmarks):

# Recognize gesture and get emoji image
emoji_img = recognize_gesture(hand_landmarks.landmark)

if emoji_img is not None:
# Display the emoji image in a separate window
cv2.imshow('Emoji', emoji_img)
Expand Down
16 changes: 8 additions & 8 deletions Algorithms/Objects/MultipleColourDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ def load_colour_ranges(csv_file):
def detect_and_draw(image, colour_ranges, selected_colours, min_area=300):
# Convert the image to HSV format
hsv_img = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

for colour in selected_colours:
lower, upper = colour_ranges[colour]
lower = np.array(lower, dtype="uint8")
upper = np.array(upper, dtype="uint8")

# Create a mask for the selected colour
mask = cv2.inRange(hsv_img, lower, upper)

# Find contours (these will be the detected objects)
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

# Draw bounding boxes around detected colours with a black line
for contour in contours:
area = cv2.contourArea(contour) # Calculate the area of the contour

if area > min_area: # Check if the area is above the minimum threshold
x, y, w, h = cv2.boundingRect(contour)
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 0), 2, lineType=cv2.LINE_AA)
Expand All @@ -63,13 +63,13 @@ def detect_and_draw(image, colour_ranges, selected_colours, min_area=300):
if not ret:
print("Error: Failed to capture image")
break

# Detect and draw bounding boxes for selected colours
result_frame = detect_and_draw(frame, colour_ranges, selected_colours, min_area=300)

# Show the result
cv2.imshow("Detected Colours", result_frame)

# Break the loop on 'q' key press
if cv2.waitKey(1) & 0xFF == ord('q'):
break
Expand Down
8 changes: 4 additions & 4 deletions Algorithms/Objects/objectDetectionImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Assuming you have opencv installed
from cv2 import cv2

MODEL = "yolov8x.pt"
MODEL = "yolov8x.pt"
# Creating an instance of your chosen model
model = YOLO(MODEL)
model = YOLO(MODEL)

results = model("../../Datasets/dogbike.jpg",show=True)
results = model("../../Datasets/dogbike.jpg",show=True)
# "0" will display the window infinitely until any keypress (in case of videos)
# waitKey(1) will display a frame for 1 ms
cv2.waitKey(0)
cv2.waitKey(0)

0 comments on commit c7812e5

Please sign in to comment.