first commit
This commit is contained in:
47
utils/detect.py
Normal file
47
utils/detect.py
Normal file
@ -0,0 +1,47 @@
|
||||
from network.vanalysis_video import vanalysis
|
||||
from utils.filter import filt
|
||||
import cv2 as cv
|
||||
from floder.config import cfg
|
||||
from utils.embedding import DataProcessing as dp
|
||||
from utils.opfile import writef, readf
|
||||
import numpy as np
|
||||
from random import choice
|
||||
|
||||
class opvideo:
|
||||
def __init__(self, flowmodel, dps):
|
||||
self.flowmodel = flowmodel
|
||||
self.dps = dps
|
||||
|
||||
def addFeature(self, uuid, num_id, video):
|
||||
imglist = filt(video)
|
||||
imgs = vanalysis(self.flowmodel, imglist)
|
||||
feature = self.dps.getFeatures(imgs)
|
||||
writef(uuid, num_id, feature)
|
||||
|
||||
def opFeature(self, uuid, finalnum, video):
|
||||
videoFeature = []
|
||||
self.addFeature(uuid, finalnum, video)
|
||||
for num_id in range(0, finalnum):
|
||||
feature = readf(uuid, num_id)
|
||||
videoFeature.append(feature)
|
||||
redic = self.opVideFeature(videoFeature)
|
||||
#print(redic)
|
||||
return redic
|
||||
|
||||
def opVideFeature(self, videoFeature):
|
||||
redic = {}
|
||||
stalist = list(range(0, len(videoFeature)))
|
||||
for nu in stalist:
|
||||
dylist = list(range(0, len(videoFeature)))
|
||||
dylist.remove(nu)
|
||||
for nn in dylist:
|
||||
nn_tmp = []
|
||||
cosin_re = self.dps.cal_cosine(
|
||||
videoFeature[nu],
|
||||
videoFeature[nn])
|
||||
if (sum(i<0.86 for i in cosin_re))>0:
|
||||
redic[nu] = False
|
||||
else:
|
||||
redic[nu] = True
|
||||
break
|
||||
return redic
|
Reference in New Issue
Block a user