test blob detection
This commit is contained in:
@@ -1,9 +1,26 @@
|
|||||||
import cv2
|
import cv2
|
||||||
from video_loader import VideoLoader
|
from video_loader import VideoLoader
|
||||||
from background_heatmap import BackgroundHeatmap
|
from background_heatmap import BackgroundHeatmap, BackgroundHeatmapFromGroup
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
params = cv2.SimpleBlobDetector_Params()
|
||||||
|
params.minThreshold = 60
|
||||||
|
params.maxThreshold = 255
|
||||||
|
# Filter by Area.
|
||||||
|
params.filterByArea = True
|
||||||
|
params.minArea = 20
|
||||||
|
params.maxArea = 25000
|
||||||
|
params.filterByCircularity = False
|
||||||
|
params.filterByColor = False
|
||||||
|
params.filterByConvexity = False
|
||||||
|
params.filterByInertia = False
|
||||||
|
params.blobColor = 255
|
||||||
|
|
||||||
|
detector = cv2.SimpleBlobDetector_create(params)
|
||||||
|
|
||||||
projects_path = "C:\\UntrackedGit\\opencv_test\\him_projects"
|
projects_path = "C:\\UntrackedGit\\opencv_test\\him_projects"
|
||||||
loader = VideoLoader(projects_path)
|
loader = VideoLoader(projects_path)
|
||||||
groups = loader.get_recordings_grouped()
|
groups = loader.get_recordings_grouped()
|
||||||
@@ -20,7 +37,18 @@ if __name__ == '__main__':
|
|||||||
# out.write(converted)
|
# out.write(converted)
|
||||||
# cv2.imshow("Heatmap", heatmap.heatmap)
|
# cv2.imshow("Heatmap", heatmap.heatmap)
|
||||||
cv2.imshow("Background filter", bgh.lastframe)
|
cv2.imshow("Background filter", bgh.lastframe)
|
||||||
|
diff = bgh.bgf_diff
|
||||||
|
|
||||||
|
# Erode dilate
|
||||||
|
kernel = np.ones((5,5),np.uint8)
|
||||||
|
diff = cv2.morphologyEx(diff, cv2.MORPH_OPEN, kernel)
|
||||||
|
|
||||||
|
keypoints = detector.detect(diff)
|
||||||
|
frame_with_keypoints = cv2.drawKeypoints(diff, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
|
||||||
|
|
||||||
|
cv2.imshow("BGF diff", frame_with_keypoints)
|
||||||
cv2.moveWindow("Background filter", 600, 100)
|
cv2.moveWindow("Background filter", 600, 100)
|
||||||
|
cv2.moveWindow("BGF diff", 1200, 100)
|
||||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||||
break
|
break
|
||||||
heatmaps.append(bgh.heatmap)
|
heatmaps.append(bgh.heatmap)
|
||||||
|
|||||||
Reference in New Issue
Block a user