| 378 | return resa, resb |
| 379 | |
| 380 | def vis_feature(frame_id,seq_num,img,track_features, det_features, cost_matrix, cost_matrix_det, cost_matrix_track,max_num=5, out_path='/home/XX/'): |
| 381 | num_zero = ["0000","000","00","0"] |
| 382 | img = cv2.resize(img, (778, 435)) |
| 383 | |
| 384 | if len(det_features) != 0: |
| 385 | max_f = det_features.max() |
| 386 | min_f = det_features.min() |
| 387 | det_features = np.round((det_features - min_f) / (max_f - min_f) * 255) |
| 388 | det_features = det_features.astype(np.uint8) |
| 389 | d_F_M = [] |
| 390 | cutpff_line = [40]*512 |
| 391 | for d_f in det_features: |
| 392 | for row in range(45): |
| 393 | d_F_M += [[40]*3+d_f.tolist()+[40]*3] |
| 394 | for row in range(3): |
| 395 | d_F_M += [[40]*3+cutpff_line+[40]*3] |
| 396 | d_F_M = np.array(d_F_M) |
| 397 | d_F_M = d_F_M.astype(np.uint8) |
| 398 | det_features_img = cv2.applyColorMap(d_F_M, cv2.COLORMAP_JET) |
| 399 | feature_img2 = cv2.resize(det_features_img, (435, 435)) |
| 400 | #cv2.putText(feature_img2, "det_features", (5, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) |
| 401 | else: |
| 402 | feature_img2 = np.zeros((435, 435)) |
| 403 | feature_img2 = feature_img2.astype(np.uint8) |
| 404 | feature_img2 = cv2.applyColorMap(feature_img2, cv2.COLORMAP_JET) |
| 405 | #cv2.putText(feature_img2, "det_features", (5, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) |
| 406 | feature_img = np.concatenate((img, feature_img2), axis=1) |
| 407 | |
| 408 | if len(cost_matrix_det) != 0 and len(cost_matrix_det[0]) != 0: |
| 409 | max_f = cost_matrix_det.max() |
| 410 | min_f = cost_matrix_det.min() |
| 411 | cost_matrix_det = np.round((cost_matrix_det - min_f) / (max_f - min_f) * 255) |
| 412 | d_F_M = [] |
| 413 | cutpff_line = [40]*len(cost_matrix_det)*10 |
| 414 | for c_m in cost_matrix_det: |
| 415 | add = [] |
| 416 | for row in range(len(c_m)): |
| 417 | add += [255-c_m[row]]*10 |
| 418 | for row in range(10): |
| 419 | d_F_M += [[40]+add+[40]] |
| 420 | d_F_M = np.array(d_F_M) |
| 421 | d_F_M = d_F_M.astype(np.uint8) |
| 422 | cost_matrix_det_img = cv2.applyColorMap(d_F_M, cv2.COLORMAP_JET) |
| 423 | feature_img2 = cv2.resize(cost_matrix_det_img, (435, 435)) |
| 424 | #cv2.putText(feature_img2, "cost_matrix_det", (5, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) |
| 425 | else: |
| 426 | feature_img2 = np.zeros((435, 435)) |
| 427 | feature_img2 = feature_img2.astype(np.uint8) |
| 428 | feature_img2 = cv2.applyColorMap(feature_img2, cv2.COLORMAP_JET) |
| 429 | #cv2.putText(feature_img2, "cost_matrix_det", (5, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) |
| 430 | feature_img = np.concatenate((feature_img, feature_img2), axis=1) |
| 431 | |
| 432 | if len(track_features) != 0: |
| 433 | max_f = track_features.max() |
| 434 | min_f = track_features.min() |
| 435 | track_features = np.round((track_features - min_f) / (max_f - min_f) * 255) |
| 436 | track_features = track_features.astype(np.uint8) |
| 437 | d_F_M = [] |