new updated
This commit is contained in:
@ -116,15 +116,19 @@ def cluster(data, thresh=0.15):
|
|||||||
return clt_center
|
return clt_center
|
||||||
|
|
||||||
def calc_simil(event, stdfeat):
|
def calc_simil(event, stdfeat):
|
||||||
|
'''事件与标准库的对比策略
|
||||||
|
该比对策略是否可以拓展到事件与事件的比对?
|
||||||
|
'''
|
||||||
|
|
||||||
def calsiml(feat1, feat2):
|
|
||||||
|
def calsiml(feat1, feat2, topkp=75, cluth=0.15):
|
||||||
'''轨迹样本和标准特征集样本相似度的选择策略'''
|
'''轨迹样本和标准特征集样本相似度的选择策略'''
|
||||||
matrix = 1 - cdist(feat1, feat2, 'cosine')
|
matrix = 1 - cdist(feat1, feat2, 'cosine')
|
||||||
simi_max = []
|
simi_max = []
|
||||||
for i in range(len(matrix)):
|
for i in range(len(matrix)):
|
||||||
sim = np.mean(get_topk_percent(matrix[i, :], 75))
|
sim = np.mean(get_topk_percent(matrix[i, :], topkp))
|
||||||
simi_max.append(sim)
|
simi_max.append(sim)
|
||||||
cltc_max = cluster(simi_max)
|
cltc_max = cluster(simi_max, cluth)
|
||||||
Simi = max(cltc_max)
|
Simi = max(cltc_max)
|
||||||
|
|
||||||
## cltc_max为空属于编程考虑不周,应予以排查解决
|
## cltc_max为空属于编程考虑不周,应予以排查解决
|
||||||
@ -194,8 +198,6 @@ def simi_matrix():
|
|||||||
if not os.path.exists(histpath):
|
if not os.path.exists(histpath):
|
||||||
os.makedirs(histpath)
|
os.makedirs(histpath)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mean_values, max_values = [], []
|
mean_values, max_values = [], []
|
||||||
cameras = ('front', 'back')
|
cameras = ('front', 'back')
|
||||||
fig, ax = plt.subplots(2, 3, figsize=(16, 9), dpi=100)
|
fig, ax = plt.subplots(2, 3, figsize=(16, 9), dpi=100)
|
||||||
|
@ -58,6 +58,12 @@ def save_imgpairs(barcode, imgpaths, matrix, savepath, thresh=(0.4, 0.6), ctype=
|
|||||||
|
|
||||||
|
|
||||||
def feat_analysis(featpath):
|
def feat_analysis(featpath):
|
||||||
|
'''
|
||||||
|
标准特征集中样本类内、类间相似度分布
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
savepath = r"D:\exhibition\result\stdfeat"
|
savepath = r"D:\exhibition\result\stdfeat"
|
||||||
|
|
||||||
InterThresh = (0.4, 0.6)
|
InterThresh = (0.4, 0.6)
|
||||||
|
18
pipeline.py
18
pipeline.py
@ -101,9 +101,9 @@ def pipeline(
|
|||||||
savepath_spdict.mkdir(parents=True, exist_ok=True)
|
savepath_spdict.mkdir(parents=True, exist_ok=True)
|
||||||
pf_path = Path(savepath_spdict) / Path(str(evtname)+".pickle")
|
pf_path = Path(savepath_spdict) / Path(str(evtname)+".pickle")
|
||||||
|
|
||||||
# if pf_path.exists():
|
if pf_path.exists():
|
||||||
# return
|
print(f"Pickle file have saved: {evtname}.pickle")
|
||||||
|
return
|
||||||
|
|
||||||
'''====================== 构造 ShoppingDict 模块 ======================='''
|
'''====================== 构造 ShoppingDict 模块 ======================='''
|
||||||
ShoppingDict = {"eventPath": eventpath,
|
ShoppingDict = {"eventPath": eventpath,
|
||||||
@ -269,25 +269,25 @@ def main():
|
|||||||
函数:pipeline(),遍历事件文件夹,选择类型 image 或 video,
|
函数:pipeline(),遍历事件文件夹,选择类型 image 或 video,
|
||||||
'''
|
'''
|
||||||
parmDict = {}
|
parmDict = {}
|
||||||
evtdir = r"\\192.168.1.28\share\测试视频数据以及日志\全实时测试\V12\2025-3-3"
|
evtdir = r"D:\works\后台回传数据"
|
||||||
parmDict["SourceType"] = "video" # video, image
|
parmDict["SourceType"] = "video" # video, image
|
||||||
parmDict["savepath"] = r"D:\全实时\202502\result"
|
parmDict["savepath"] = r"D:\works\results"
|
||||||
parmDict["weights"] = r'D:\DetectTracking\ckpts\best_cls10_0906.pt'
|
parmDict["weights"] = r'D:\DetectTracking\ckpts\best_cls10_0906.pt'
|
||||||
|
|
||||||
evtdir = Path(evtdir)
|
evtdir = Path(evtdir)
|
||||||
k, errEvents = 0, []
|
k, errEvents = 0, []
|
||||||
for item in evtdir.iterdir():
|
for item in evtdir.iterdir():
|
||||||
if item.is_dir():
|
if item.is_dir():
|
||||||
item = evtdir/Path("20250303-103058-074_6914973604223_6914973604223")
|
# item = evtdir/Path("20250303-103058-074_6914973604223_6914973604223")
|
||||||
parmDict["eventpath"] = item
|
parmDict["eventpath"] = item
|
||||||
# pipeline(**parmDict)
|
# pipeline(**parmDict)
|
||||||
try:
|
try:
|
||||||
pipeline(**parmDict)
|
pipeline(**parmDict)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errEvents.append(str(item))
|
errEvents.append(str(item))
|
||||||
k+=1
|
# k+=1
|
||||||
if k==1:
|
# if k==1:
|
||||||
break
|
# break
|
||||||
|
|
||||||
errfile = os.path.join(parmDict["savepath"], f'error_events.txt')
|
errfile = os.path.join(parmDict["savepath"], f'error_events.txt')
|
||||||
with open(errfile, 'w', encoding='utf-8') as f:
|
with open(errfile, 'w', encoding='utf-8') as f:
|
||||||
|
29
说明文档.txt
29
说明文档.txt
@ -178,6 +178,28 @@
|
|||||||
root_dir:文件夹,包含"subimgs"字段,对该文件夹中的相邻图像进行相似度比较
|
root_dir:文件夹,包含"subimgs"字段,对该文件夹中的相邻图像进行相似度比较
|
||||||
silimarity_compare()
|
silimarity_compare()
|
||||||
功能:对imgpaths文件夹中的图像进行相似度比较
|
功能:对imgpaths文件夹中的图像进行相似度比较
|
||||||
|
select_subimgs.py
|
||||||
|
为吴华琦实现的样本选择程序
|
||||||
|
|
||||||
|
|
||||||
|
event_test.py
|
||||||
|
calc_simil(event, stdfeat)
|
||||||
|
事件与标准库的对比策略,该函数在one2one_contrast.py中调用
|
||||||
|
calsiml(feat1, feat2, topkp=75, cluth=0.15):
|
||||||
|
功能:计算2个样本集的相似度
|
||||||
|
(1)(feat1, feat2),对于单样本,选择 topkp 的相似度,并求均值,得到单样本对另一个特征集的相似度;
|
||||||
|
(2)simi_max:样本集 feat1 对样本集 feat2 的相似度,是一个向量
|
||||||
|
(3)对 simi_max 进行聚类,阈值为 cluth,选取值最大的聚类中心,作为2个样本集相似度的度量
|
||||||
|
前后摄轨迹选择:
|
||||||
|
情况1:前后摄轨迹(与标准集的)相似度的差 > 阈值,表明前后摄中有一个轨迹与标准集相差较远,丢弃相应轨迹,保留具有较大相似度的轨迹
|
||||||
|
情况2:前后摄轨迹(与标准集的)相似度的差 >=阈值,表明前后摄轨迹与标准集均相似,求轨迹相似度均值
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
input_getout_compare.py
|
input_getout_compare.py
|
||||||
creatd_deletedBarcode_front(filepath)
|
creatd_deletedBarcode_front(filepath)
|
||||||
@ -191,7 +213,12 @@
|
|||||||
precision_compare(filepath, savepath)
|
precision_compare(filepath, savepath)
|
||||||
读取 deletedBarcode.txt 和 deletedBarcodeTest.txt 中的数据,进行相似度比较
|
读取 deletedBarcode.txt 和 deletedBarcodeTest.txt 中的数据,进行相似度比较
|
||||||
|
|
||||||
stdfeat_analys()
|
stdfeat_analys():
|
||||||
|
feat_analysis(featpath): 标准特征集中样本类内、类间相似度分布
|
||||||
|
|
||||||
|
feat_infer.py
|
||||||
|
简单的subimg特征提取
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
genfeats.py
|
genfeats.py
|
||||||
|
Reference in New Issue
Block a user