-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpeed_new_version_try.py
50 lines (34 loc) · 1.11 KB
/
Speed_new_version_try.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import numpy as np
import cv2
from multiprocessing import Process, Queue
from Queue import Empty
from matplotlib import pyplot as plt
from decimal import Decimal
import math
import copy
import argparse
import glob
import multiprocessing
frameCount = 20
#GLOBAL FRAME ARRAY
frameQueue = [20]
def speed_Estimation(currentFrame_index, currentFrame):
im_height= np.size(currentFrame, 0)
im_width = np.size(currentFrame, 1)
bestDiff_yet = 255*im_width*im_height
for offset in range(4, 20):
compare_index = np.mod(currentFrame_index - offset, 20)
im_A = frameQueue[:, :, currentFrame_index]
im_B = frameQueue[:, :, compare_index]
this_difference = sum(abs(im_A - im_B))
if this_difference < bestDiff_yet:
bestDiff_yet = this_difference
best_offset = offset
video_file = ('Road_Video.AVI')
cap = cv2.VideoCapture(video_file)
for frame in range(frameCount):
ret, frameQueue[frame] = cap.read()
frameCount = 0
for frames in range(21, 100, 20):
currentFrame = frame_mod(frameNumber, QueueSize)
frames[currentFrame] = read_Frame(frameNumber)