guoqing bakeup
This commit is contained in:
95
pipeline.py
Normal file
95
pipeline.py
Normal file
@ -0,0 +1,95 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Sun Sep 29 08:59:21 2024
|
||||
|
||||
@author: ym
|
||||
"""
|
||||
import os
|
||||
import cv2
|
||||
from pathlib import Path
|
||||
from track_reid import parse_opt, yolo_resnet_tracker
|
||||
|
||||
from tracking.dotrack.dotracks_back import doBackTracks
|
||||
from tracking.dotrack.dotracks_front import doFrontTracks
|
||||
|
||||
IMGFORMATS = '.bmp', '.jpeg', '.jpg', 'png', 'tif', 'tiff', 'webp', 'pfm'
|
||||
VIDFORMATS = '.avi', '.gif', '.m4v', '.mkv', '.mov', '.mp4', '.ts', '.wmv'
|
||||
|
||||
std_feature_path = r"\\192.168.1.28\share\测试_202406\contrast\std_features_2192_ft32vsft16"
|
||||
|
||||
|
||||
opt = parse_opt()
|
||||
optdict = vars(opt)
|
||||
|
||||
def get_video_pairs(vpath):
|
||||
vdieopath = []
|
||||
for filename in os.listdir(vpath):
|
||||
file, ext = os.path.splitext(filename)
|
||||
if ext in VIDFORMATS:
|
||||
vdieopath.append(os.path.join(vpath, filename))
|
||||
return vdieopath
|
||||
|
||||
|
||||
def pipeline():
|
||||
eventpath = r"\\192.168.1.28\share\测试_202406\0918\images1\20240918-110913-c3a7e4d9-23d4-4a6f-a23f-a2eeee510536_6939947701616"
|
||||
savepath = r"D:\contrast\detect"
|
||||
|
||||
optdict["project"] = savepath
|
||||
eventname = os.path.basename(eventpath)
|
||||
|
||||
vpaths = get_video_pairs(eventpath)
|
||||
event_tracks = []
|
||||
for vpath in vpaths:
|
||||
|
||||
'''事件结果文件夹'''
|
||||
save_dir_event = Path(savepath) / Path(eventname)
|
||||
save_dir_img = save_dir_event / Path(str(Path(vpath).stem))
|
||||
if not save_dir_img.exists():
|
||||
save_dir_img.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
'''Yolo + Resnet + Tracker'''
|
||||
optdict["source"] = vpath
|
||||
optdict["save_dir"] = save_dir_img
|
||||
optdict["nosave"] = False
|
||||
|
||||
tracksdict = yolo_resnet_tracker(**optdict)
|
||||
|
||||
bboxes = tracksdict['TrackBoxes']
|
||||
|
||||
bname = os.path.basename(vpath)
|
||||
if bname.split('_')[0] == "0" or bname.find('back')>=0:
|
||||
vts = doFrontTracks(bboxes, tracksdict)
|
||||
vts.classify()
|
||||
|
||||
event_tracks.append(("back", vts))
|
||||
|
||||
if bname.split('_')[0] == "1" or bname.find('front')>=0:
|
||||
vts = doBackTracks(bboxes, tracksdict)
|
||||
vts.classify()
|
||||
event_tracks.append(("front", vts))
|
||||
|
||||
|
||||
for CamerType, vts in event_tracks:
|
||||
if CamerType == 'back':
|
||||
pass
|
||||
if CamerType == 'front':
|
||||
pass
|
||||
|
||||
|
||||
for featname in os.listdir(std_feature_path):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
pipeline()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user