Poprawki
This commit is contained in:
parent
8d1e15b2f5
commit
ebba05b5f2
12
main.py
12
main.py
@ -28,6 +28,8 @@ if __name__ == "__main__":
|
|||||||
tfile = tempfile.NamedTemporaryFile(delete=False)
|
tfile = tempfile.NamedTemporaryFile(delete=False)
|
||||||
tfile.write(upload_movie.read())
|
tfile.write(upload_movie.read())
|
||||||
video_cap = cv.VideoCapture(tfile.name)
|
video_cap = cv.VideoCapture(tfile.name)
|
||||||
|
font = cv.FONT_HERSHEY_SIMPLEX
|
||||||
|
|
||||||
result, num, frames = segment_video(video_cap, fps=3)
|
result, num, frames = segment_video(video_cap, fps=3)
|
||||||
st.write(f"Załadowano {num} klatek")
|
st.write(f"Załadowano {num} klatek")
|
||||||
classifications = []
|
classifications = []
|
||||||
@ -38,8 +40,15 @@ if __name__ == "__main__":
|
|||||||
img_np = np.asarray(img2)
|
img_np = np.asarray(img2)
|
||||||
classification = classify(img_np[:,:,::-1], model)
|
classification = classify(img_np[:,:,::-1], model)
|
||||||
classifications.append(classification)
|
classifications.append(classification)
|
||||||
|
cv.putText(img_skeleton,
|
||||||
|
classification,
|
||||||
|
(20, 50),
|
||||||
|
font, 2,
|
||||||
|
(255, 255, 255),
|
||||||
|
6,
|
||||||
|
cv.LINE_4)
|
||||||
|
|
||||||
st.image(img_skeleton[:,:,::-1])
|
st.image(img_skeleton[:,:,::-1])
|
||||||
st.write(classification)
|
|
||||||
i = 0
|
i = 0
|
||||||
last_letter = ''
|
last_letter = ''
|
||||||
text = ''
|
text = ''
|
||||||
@ -59,7 +68,6 @@ if __name__ == "__main__":
|
|||||||
frame_index = frames.index(i)
|
frame_index = frames.index(i)
|
||||||
letter = classifications[frame_index]
|
letter = classifications[frame_index]
|
||||||
last_letter = letter
|
last_letter = letter
|
||||||
st.write(last_letter)
|
|
||||||
cv.putText(frame,
|
cv.putText(frame,
|
||||||
last_letter,
|
last_letter,
|
||||||
(50, 50),
|
(50, 50),
|
||||||
|
@ -17,6 +17,7 @@ def segment_video(video, fps=5):
|
|||||||
n = real_fps / fps
|
n = real_fps / fps
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
frames_nums = []
|
||||||
i=0
|
i=0
|
||||||
num = 0
|
num = 0
|
||||||
while True:
|
while True:
|
||||||
@ -25,10 +26,11 @@ def segment_video(video, fps=5):
|
|||||||
break
|
break
|
||||||
if i % n == 0:
|
if i % n == 0:
|
||||||
result.append(frame)
|
result.append(frame)
|
||||||
|
frames_nums.append(i)
|
||||||
num += 1
|
num += 1
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
return result, num
|
return result, num, frames_nums
|
||||||
|
|
||||||
def save_frames(frames, dir):
|
def save_frames(frames, dir):
|
||||||
detector = HandDetector(maxHands=1, mode=True, detectionCon=0.7, minTrackCon=0.8)
|
detector = HandDetector(maxHands=1, mode=True, detectionCon=0.7, minTrackCon=0.8)
|
||||||
|
Loading…
Reference in New Issue
Block a user