detec
BIN
detec/calibresult1.png
Normal file
After Width: | Height: | Size: 324 KiB |
BIN
detec/calibresult2.png
Normal file
After Width: | Height: | Size: 324 KiB |
26
detec/camera.py
Normal file
@ -0,0 +1,26 @@
|
||||
# import the opencv library
|
||||
import cv2
|
||||
|
||||
|
||||
# define a video capture object
|
||||
vid = cv2.VideoCapture('rtsp://SF2023:SF2023@129.175.55.62:88/videoMain')
|
||||
|
||||
while(True):
|
||||
|
||||
# Capture the video frame
|
||||
# by frame
|
||||
ret, frame = vid.read()
|
||||
|
||||
# Display the resulting frame
|
||||
cv2.imshow('frame', frame)
|
||||
|
||||
# the 'q' button is set as the
|
||||
# quitting button you may use any
|
||||
# desired button of your choice
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
break
|
||||
|
||||
# After the loop release the cap object
|
||||
vid.release()
|
||||
# Destroy all the windows
|
||||
cv2.destroyAllWindows()
|
BIN
detec/data/left01.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
detec/data/left02.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
detec/data/left03.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
detec/data/left04.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
detec/data/left05.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
detec/data/left06.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
detec/data/left07.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
detec/data/left08.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
detec/data/left09.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
detec/data/left11.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
detec/data/left12.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
detec/data/left13.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
detec/data/left14.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
detec/foscam/1.jpg
Normal file
After Width: | Height: | Size: 229 KiB |
BIN
detec/foscam/2.jpg
Normal file
After Width: | Height: | Size: 220 KiB |
BIN
detec/foscam/3.jpg
Normal file
After Width: | Height: | Size: 213 KiB |
BIN
detec/foscam/4.jpg
Normal file
After Width: | Height: | Size: 220 KiB |
BIN
detec/foscam/5.jpg
Normal file
After Width: | Height: | Size: 224 KiB |
@ -0,0 +1,58 @@
|
||||
import os
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import cv2
|
||||
import time
|
||||
|
||||
cap = cv2.VideoCapture('cams/10s.mp4')
|
||||
folder_path = "track/exp2/labels/"
|
||||
name = '10s'
|
||||
fps = 141
|
||||
|
||||
allfiles = []
|
||||
for i in range(1,fps+1):
|
||||
allfiles.append(folder_path + name + '_' + str(i) + '.txt')
|
||||
|
||||
width = 480
|
||||
height = 360
|
||||
|
||||
frame_nb = 0
|
||||
|
||||
if (cap.isOpened()== False):
|
||||
print("Error opening video stream or file")
|
||||
while(cap.isOpened()):
|
||||
|
||||
ret, frame = cap.read()
|
||||
if ret == True:
|
||||
|
||||
df = pd.read_csv(allfiles[frame_nb], header=None, sep=' ')
|
||||
|
||||
for index, row in df.iterrows():
|
||||
class_id, center_x, center_y, bbox_width, bbox_height, object_id = row
|
||||
|
||||
center_x = int(center_x * width)
|
||||
center_y = int(center_y * height)
|
||||
bbox_width = int(bbox_width * width)
|
||||
bbox_height = int(bbox_height * height)
|
||||
|
||||
top_left_x = int(center_x - bbox_width / 2)
|
||||
top_left_y = int(center_y - bbox_height / 2)
|
||||
bottom_right_x = int(center_x + bbox_width / 2)
|
||||
bottom_right_y = int(center_y + bbox_height / 2)
|
||||
|
||||
cv2.rectangle(frame, (top_left_x, top_left_y), (bottom_right_x, bottom_right_y), (255, 0, 0), 2)
|
||||
|
||||
label = f'Class: {int(class_id)}, Object ID: {int(object_id)}'
|
||||
cv2.putText(frame, label, (top_left_x, top_left_y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 1)
|
||||
|
||||
cv2.imshow('Frame',frame)
|
||||
|
||||
if cv2.waitKey(25) & 0xFF == ord('q'):
|
||||
break
|
||||
|
||||
frame_nb = frame_nb + 1
|
||||
|
||||
else:
|
||||
break
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
30
detec/opencv.py
Normal file
@ -0,0 +1,30 @@
|
||||
import numpy as np
|
||||
import cv2
|
||||
import time
|
||||
|
||||
cap = cv2.VideoCapture('cams/10s.mp4')
|
||||
|
||||
# if (cap.isOpened()== False):
|
||||
# print("Error opening video stream or file")
|
||||
|
||||
# while(cap.isOpened()):
|
||||
# ret, frame = cap.read()
|
||||
# if ret == True:
|
||||
# cv2.imshow('Frame',frame)
|
||||
# if cv2.waitKey(25) & 0xFF == ord('q'):
|
||||
# break
|
||||
# else:
|
||||
# break
|
||||
|
||||
# cap.release()
|
||||
# cv2.destroyAllWindows()
|
||||
|
||||
while True:
|
||||
ret, image = cap.read()
|
||||
# this is the part to add to your code
|
||||
cv2.rectangle(image, (0, 0), (200, 200), (0, 0, 0), -1)
|
||||
|
||||
cv2.imshow("My Video", image)
|
||||
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
cv2.destroyAllWindows()
|
@ -1,15 +0,0 @@
|
||||
import numpy as np
|
||||
import cv2 as cv
|
||||
cap = cv.VideoCapture('cams/10s.mp4')
|
||||
while cap.isOpened():
|
||||
ret, frame = cap.read()
|
||||
# if frame is read correctly ret is True
|
||||
if not ret:
|
||||
print("Can't receive frame (stream end?). Exiting ...")
|
||||
break
|
||||
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
|
||||
cv.imshow('frame', gray)
|
||||
if cv.waitKey(1) == ord('q'):
|
||||
break
|
||||
cap.release()
|
||||
cv.destroyAllWindows()
|
37
detec/tutocalibration.py
Normal file
@ -0,0 +1,37 @@
|
||||
import numpy as np
|
||||
import cv2 as cv
|
||||
import glob
|
||||
# termination criteria
|
||||
criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 30, 0.001)
|
||||
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
|
||||
objp = np.zeros((6*7,3), np.float32)
|
||||
objp[:,:2] = np.mgrid[0:7,0:6].T.reshape(-1,2)
|
||||
# Arrays to store object points and image points from all the images.
|
||||
objpoints = [] # 3d point in real world space
|
||||
imgpoints = [] # 2d points in image plane.
|
||||
# images = glob.glob('detec/foscam/*.png')
|
||||
images = glob.glob('detec/foscam/*.jpg')
|
||||
|
||||
|
||||
for fname in images:
|
||||
img = cv.imread(fname)
|
||||
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
|
||||
# Find the chess board corners
|
||||
ret, corners = cv.findChessboardCorners(gray, (7,6), None)
|
||||
# If found, add object points, image points (after refining them)
|
||||
if ret == True:
|
||||
objpoints.append(objp)
|
||||
corners2 = cv.cornerSubPix(gray,corners, (11,11), (-1,-1), criteria)
|
||||
imgpoints.append(corners2)
|
||||
# Draw and display the corners
|
||||
cv.drawChessboardCorners(img, (7,6), corners2, ret)
|
||||
cv.imshow('img', img)
|
||||
cv.waitKey(500)
|
||||
cv.destroyAllWindows()
|
||||
|
||||
ret, mtx, dist, rvecs, tvecs = cv.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)
|
||||
|
||||
|
||||
img = cv.imread('detec/foscam/1.jpg')
|
||||
h, w = img.shape[:2]
|
||||
newcameramtx, roi = cv.getOptimalNewCameraMatrix(mtx, dist, (w,h), 1, (w,h))
|
BIN
track/exp2/crops/2/1/10s.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
track/exp2/crops/2/1/10s2.jpg
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
track/exp2/crops/2/1/10s3.jpg
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
track/exp2/crops/2/10/10s.jpg
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
track/exp2/crops/2/10/10s2.jpg
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
track/exp2/crops/2/10/10s3.jpg
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
track/exp2/crops/2/11/10s.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s10.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s100.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s101.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s102.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s103.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s104.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s105.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s106.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s107.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s108.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s109.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s11.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s110.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s111.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s112.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s113.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s114.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s115.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s116.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s117.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s118.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s12.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s13.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s14.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s15.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s16.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s17.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s18.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s19.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s2.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s20.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s21.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s22.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s23.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s24.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s25.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s26.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s27.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s28.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s29.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s3.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s30.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s31.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s32.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s33.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s34.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s35.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s36.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s37.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s38.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s39.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s4.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s40.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s41.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s42.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s43.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s44.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s45.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s46.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s47.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s48.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s49.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s5.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s50.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s51.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s52.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s53.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
track/exp2/crops/2/11/10s54.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |