• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
yjyoon / Raindrop_Detection star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
Raindrop_Detectionmain.py
Download as .zip file
File name
Commit message
Commit date
data
data cleaning
2023-07-12
model
small fix for return type of networks
2023-07-24
tools
dataloader refactoring
2023-07-13
.gitignore
data cleaning
2023-07-12
README.md
readme update
2023-06-21
batchmix.png
theorizing train code for GAN
2023-06-22
binary mask map test.py
data cleaning
2023-07-12
datasetmananger.py
theorizing about dataset management
2023-06-23
inference.py
configuring saving method and inference method for model
2023-07-11
main.py
Hello YONA
2023-06-21
train.py
dataloader refactoring
2023-07-13
juni 2023-06-21 fdc2bde Hello YONA UNIX
Raw Open in browser Change history
import cv2 import torch import numpy as np from ImageProcessing import MSCN from torchvision.io import read_image # Create a background subtractor object bg_subtractor = cv2.bgsegm.createBackgroundSubtractorGMG() kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(1,10)) # Open video file or capture device video = cv2.VideoCapture('spring_-_38344 (Original).mp4') # Minimum and maximum area thresholds for filtering objects min_area = 1 # Adjust as needed max_area = 500 # Adjust as needed frame_count = 0 while True: # Read frame from video ret, frame = video.read() if not ret: break # Apply background subtraction fg_mask = bg_subtractor.apply(frame) fg_mask = cv2.morphologyEx(fg_mask, cv2.MORPH_OPEN, kernel) # Apply thresholding to get binary foreground mask thresh = cv2.threshold(fg_mask, 128, 255, cv2.THRESH_BINARY)[1] # Find contours of the moving objects contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # Filter objects by size for contour in contours: # Calculate contour area area = cv2.contourArea(contour) # Check if contour area is within the specified range if min_area < area < max_area : (x, y, w, h) = cv2.boundingRect(contour) cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) # Display the resulting frame if frame_count > 120 : cv2.imshow('Moving Object Detection', frame) # cv2.imshow('movingobjectcontour', fg_mask) # Exit if 'q' is pressed frame_count += 1 if cv2.waitKey(1) & 0xFF == ord('q'): break # Release the video capture and close windows video.release() cv2.destroyAllWindows()

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up