pepeline_extract_subimg.py: extract subimg
This commit is contained in:
109
pipeline.py
109
pipeline.py
@ -6,6 +6,7 @@ Created on Sun Sep 29 08:59:21 2024
|
||||
"""
|
||||
import os
|
||||
import cv2
|
||||
import pickle
|
||||
from pathlib import Path
|
||||
from track_reid import parse_opt, yolo_resnet_tracker
|
||||
|
||||
@ -21,21 +22,49 @@ std_feature_path = r"\\192.168.1.28\share\测试_202406\contrast\std_features_21
|
||||
opt = parse_opt()
|
||||
optdict = vars(opt)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_interbcd_inputenents():
|
||||
bcdpath = r"\\192.168.1.28\share\测试_202406\contrast\std_barcodes_2192"
|
||||
eventpath = r"\\192.168.1.28\share\测试_202406\0918"
|
||||
|
||||
barcodes = []
|
||||
eventpaths = []
|
||||
for featname in os.listdir(bcdpath):
|
||||
barcode, ext = os.path.splitext(featname)
|
||||
barcodes.append(barcode)
|
||||
|
||||
input_enents = []
|
||||
for root, dirs, files in os.walk(eventpath):
|
||||
input_enent = [os.path.join(root, d) for d in dirs if d.split('_')[-1] in barcodes]
|
||||
|
||||
input_enents.extend(input_enent)
|
||||
|
||||
|
||||
return input_enents
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
return vdieopath
|
||||
|
||||
def pipeline():
|
||||
eventpath = r"\\192.168.1.28\share\测试_202406\0918\images1\20240918-110913-c3a7e4d9-23d4-4a6f-a23f-a2eeee510536_6939947701616"
|
||||
def pipeline(eventpath, stdfeat_path):
|
||||
# eventpath = r"\\192.168.1.28\share\测试_202406\0918\images1\20240918-110822-1bc3902e-5a8e-4e23-8eca-fb3f02738551_6938314601726"
|
||||
|
||||
savepath = r"D:\contrast\detect"
|
||||
|
||||
optdict["project"] = savepath
|
||||
|
||||
eventname = os.path.basename(eventpath)
|
||||
barcode = eventname.split('_')[-1]
|
||||
|
||||
|
||||
vpaths = get_video_pairs(eventpath)
|
||||
event_tracks = []
|
||||
@ -75,9 +104,19 @@ def pipeline():
|
||||
if CamerType == 'front':
|
||||
pass
|
||||
|
||||
'''前后摄轨迹选择'''
|
||||
|
||||
|
||||
if stdfeat_path is not None:
|
||||
with open(stdfeat_path, 'rb') as f:
|
||||
featDict = pickle.load(f)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for featname in os.listdir(std_feature_path):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@ -88,7 +127,63 @@ def pipeline():
|
||||
|
||||
|
||||
def main():
|
||||
pipeline()
|
||||
bcdpath = r"\\192.168.1.28\share\测试_202406\contrast\std_barcodes_2192"
|
||||
eventpath = r"\\192.168.1.28\share\测试_202406\0918\images1"
|
||||
|
||||
|
||||
barcodes = []
|
||||
input_enents = []
|
||||
output_events = []
|
||||
|
||||
|
||||
# input_enents = get_interbcd_inputenents()
|
||||
# k = 0
|
||||
# for event in input_enents:
|
||||
# pipeline(event)
|
||||
|
||||
# k += 1
|
||||
# if k ==1:
|
||||
# break
|
||||
|
||||
|
||||
'''1. 获得barcode标准特征集列表'''
|
||||
for featname in os.listdir(bcdpath):
|
||||
barcode, ext = os.path.splitext(featname)
|
||||
if not barcode.isdigit() or len(barcode)<=8 or ext != ".pickle" :
|
||||
continue
|
||||
barcodes.append(barcode)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for filename in os.listdir(eventpath):
|
||||
bcd = filename.split('_')[-1]
|
||||
|
||||
event_path = os.path.join(eventpath, filename)
|
||||
stdfeat_path = None
|
||||
if bcd in barcodes:
|
||||
stdfeat_path = os.path.join(bcdpath, f"{bcd}.pickle")
|
||||
|
||||
input_enents.append((event_path, stdfeat_path))
|
||||
|
||||
|
||||
|
||||
|
||||
for eventpath, stdfeat_path in input_enents:
|
||||
pipeline(eventpath, stdfeat_path)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user