Skip to content

Comments

Task 5#3

Open
gitfrandu4 wants to merge 1 commit intomainfrom
task-5
Open

Task 5#3
gitfrandu4 wants to merge 1 commit intomainfrom
task-5

Conversation

@gitfrandu4
Copy link
Owner

Script:

import cv2
import numpy as np
import matplotlib.pyplot as plt

# Initialize variables
vid = cv2.VideoCapture('AyagauresResult.m4v')
font = cv2.FONT_HERSHEY_SIMPLEX
initial_frame = None

while(True):
    ret, frame = vid.read()
    if ret:
        # Convert frame to grayscale with shape
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        
        # Find the darkest and brightest pixels
        min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(gray)
        
        # Mark the darkest pixel
        cv2.circle(frame, min_loc, 5, (255, 0, 0), 2)  # Blue circle
        cv2.putText(frame, 'Darkest', (min_loc[0] + 5, min_loc[1] - 5), font, 0.5, (255, 0, 0), 2)
        
        # Mark the brightest pixel
        cv2.circle(frame, max_loc, 5, (0, 0, 255), 2)  # Red circle
        cv2.putText(frame, 'Brightest', (max_loc[0] + 5, max_loc[1] - 5), font, 0.5, (0, 0, 255), 2)
        
        # Display the frame
        cv2.imshow('Cam', frame)

        if initial_frame is None:
            plt.imshow(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
            plt.axis('off')
            plt.show()
            initial_frame = frame
        
    if cv2.waitKey(20) == 27: 
        break

vid.release()
cv2.destroyAllWindows()

Resultado:

image

@gitfrandu4 gitfrandu4 requested a review from DerKom September 15, 2024 12:14
@gitfrandu4 gitfrandu4 self-assigned this Sep 15, 2024
@gitfrandu4 gitfrandu4 added the enhancement New feature or request label Sep 15, 2024
@gitfrandu4 gitfrandu4 changed the title update VC_P1.ipynb with task5 Task 5 Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants