diff --git a/data_sub/test_3_fix/data_sub.json b/data_sub/test_3_fix/data_sub.json new file mode 100644 index 0000000..d70de6e --- /dev/null +++ b/data_sub/test_3_fix/data_sub.json @@ -0,0 +1,122 @@ +[ + { + "label": 0, + "prob": 0.9319185018539429, + "x": 210, + "y": 111, + "width": 55, + "height": 52 + }, + { + "label": 0, + "prob": 0.9214611649513245, + "x": 337, + "y": 214, + "width": 66, + "height": 66 + }, + { + "label": 0, + "prob": 0.9198867082595825, + "x": 262, + "y": 262, + "width": 45, + "height": 42 + }, + { + "label": 0, + "prob": 0.9190443158149719, + "x": 288, + "y": 95, + "width": 42, + "height": 40 + }, + { + "label": 0, + "prob": 0.8733175992965698, + "x": 314, + "y": 168, + "width": 37, + "height": 34 + }, + { + "label": 0, + "prob": 0.8678057193756104, + "x": 359, + "y": 97, + "width": 41, + "height": 38 + }, + { + "label": 0, + "prob": 0.8506720662117004, + "x": 216, + "y": 212, + "width": 89, + "height": 38 + }, + { + "label": 0, + "prob": 0.8226487636566162, + "x": 362, + "y": 146, + "width": 36, + "height": 35 + }, + { + "label": 0, + "prob": 0.5786533355712891, + "x": 55, + "y": 98, + "width": 42, + "height": 39 + }, + { + "label": 0, + "prob": 0.5088553428649902, + "x": 93, + "y": 215, + "width": 70, + "height": 69 + }, + { + "label": 0, + "prob": 0.3739035725593567, + "x": 191, + "y": 314, + "width": 188, + "height": 36 + }, + { + "label": 0, + "prob": 0.3039762079715729, + "x": 0, + "y": 117, + "width": 37, + "height": 54 + }, + { + "x": 125, + "y": 95, + "width": 42, + "height": 44 + }, + { + "x": 78, + "y": 169, + "width": 36, + "height": 36 + }, + { + "x": 26, + "y": 263, + "width": 43, + "height": 40 + }, + { + "x": 125, + "y": 144, + "width": 37, + "height": 37 + } +] \ No newline at end of file diff --git a/data_sub/test_3_fix/wide_image.png b/data_sub/test_3_fix/wide_image.png new file mode 100644 index 0000000..ed2a99f Binary files /dev/null and b/data_sub/test_3_fix/wide_image.png differ diff --git a/data_sub/test_5/data_sub.json b/data_sub/test_5/data_sub.json new file mode 100644 index 0000000..dac6b81 --- /dev/null +++ b/data_sub/test_5/data_sub.json @@ -0,0 +1,202 @@ +[ + { + "label": 0, + "prob": 0.976456344127655, + "x": 127, + "y": 248, + "width": 43, + "height": 43 + }, + { + "label": 0, + "prob": 0.9754061698913574, + "x": 387, + "y": 87, + "width": 45, + "height": 44 + }, + { + "label": 0, + "prob": 0.972541093826294, + "x": 599, + "y": 103, + "width": 37, + "height": 40 + }, + { + "label": 0, + "prob": 0.9724580645561218, + "x": 536, + "y": 114, + "width": 52, + "height": 52 + }, + { + "label": 0, + "prob": 0.9701502919197083, + "x": 583, + "y": 256, + "width": 37, + "height": 40 + }, + { + "label": 0, + "prob": 0.9693725109100342, + "x": 321, + "y": 204, + "width": 84, + "height": 43 + }, + { + "label": 0, + "prob": 0.9686949253082275, + "x": 433, + "y": 207, + "width": 65, + "height": 68 + }, + { + "label": 0, + "prob": 0.9675657749176025, + "x": 364, + "y": 252, + "width": 44, + "height": 44 + }, + { + "label": 0, + "prob": 0.9660161733627319, + "x": 312, + "y": 104, + "width": 57, + "height": 58 + }, + { + "label": 0, + "prob": 0.9660087823867798, + "x": 84, + "y": 201, + "width": 84, + "height": 38 + }, + { + "label": 0, + "prob": 0.9629431962966919, + "x": 521, + "y": 301, + "width": 117, + "height": 42 + }, + { + "label": 0, + "prob": 0.9622830152511597, + "x": 415, + "y": 161, + "width": 37, + "height": 37 + }, + { + "label": 0, + "prob": 0.959924578666687, + "x": 80, + "y": 99, + "width": 56, + "height": 55 + }, + { + "label": 0, + "prob": 0.9588371515274048, + "x": 197, + "y": 200, + "width": 70, + "height": 67 + }, + { + "label": 0, + "prob": 0.9577850103378296, + "x": 547, + "y": 209, + "width": 71, + "height": 39 + }, + { + "label": 0, + "prob": 0.9575106501579285, + "x": 178, + "y": 156, + "width": 38, + "height": 37 + }, + { + "label": 0, + "prob": 0.9565834999084473, + "x": 155, + "y": 83, + "width": 43, + "height": 43 + }, + { + "label": 0, + "prob": 0.954764723777771, + "x": 456, + "y": 92, + "width": 44, + "height": 44 + }, + { + "label": 0, + "prob": 0.9506204724311829, + "x": 60, + "y": 295, + "width": 178, + "height": 40 + }, + { + "label": 0, + "prob": 0.9491816163063049, + "x": 295, + "y": 299, + "width": 176, + "height": 45 + }, + { + "label": 0, + "prob": 0.9482607245445251, + "x": 223, + "y": 83, + "width": 46, + "height": 43 + }, + { + "label": 0, + "prob": 0.9400599002838135, + "x": 225, + "y": 132, + "width": 41, + "height": 39 + }, + { + "label": 0, + "prob": 0.9303370714187622, + "x": 622, + "y": 171, + "width": 16, + "height": 37 + }, + { + "label": 0, + "prob": 0.9053900837898254, + "x": 461, + "y": 140, + "width": 36, + "height": 36 + }, + { + "label": 0, + "prob": 0.06086902320384979, + "x": 630, + "y": 102, + "width": 8, + "height": 45 + } +] \ No newline at end of file diff --git a/data_sub/test_5/wide_image.png b/data_sub/test_5/wide_image.png new file mode 100644 index 0000000..ee05e4e Binary files /dev/null and b/data_sub/test_5/wide_image.png differ diff --git a/environment.yaml b/environment.yml similarity index 100% rename from environment.yaml rename to environment.yml diff --git a/search.py b/search.py index 869e7b9..993e0ef 100644 --- a/search.py +++ b/search.py @@ -481,12 +481,16 @@ def search(data_bim_json, data_sub_json, wide_cam_img_width, wide_cam_img_height h = contour["height"] # 由于定位框大小大于预埋件大小,因此这里需要做缩放处理 - kh = int(h * 0.01) # roi1 - kw = int(w * 0.01) # roi1 - x += int(kw) - y += int(kh) - w -= int(kw) - h -= int(kh) + # kh = int(h * 0.17) # roi1 + # kw = int(w * 0.17) # roi1 + # x += int(kw) + # y += int(kh) + # w -= int(kw) + # h -= int(kh) + x += 5 + y += 5 + w -= 10 + h -= 10 param = {} param["x1"] = x param["y1"] = y @@ -743,7 +747,7 @@ if __name__ == "__main__": # ====================== 广角定位 开始 ========================= data_bim_json = read_from_json("data_bim.json") # bim数据 - data_sub_json = read_from_json("data_sub/test_1/data_sub.json") # 广角识别之后的ROI数据 + data_sub_json = read_from_json("data_sub/test_5/data_sub.json") # 广角识别之后的ROI数据 wide_cam_img_width = 640 wide_cam_img_height = 480 bim_sub_area = search(data_bim_json, data_sub_json, wide_cam_img_width, wide_cam_img_height) @@ -766,12 +770,13 @@ if __name__ == "__main__": # ========== 下面仅仅是测试画效果图 开始 ========== # 画出广角相机矩形框 + print("画出广角相机矩形框") + print(f"起始点:{bim_sub_area['start_point']}") + print(f"结束点:{bim_sub_area['end_point']}") cv2.rectangle(bim_im, bim_sub_area["start_point"], bim_sub_area["end_point"], 100, 50) # 画出高清相机矩形框 cv2.rectangle(bim_im, (bim_sub_area["hd_cam_x_bim"], bim_sub_area["hd_cam_y_bim"]), ( bim_sub_area["hd_cam_x_bim"] + bim_sub_area["hd_cam_w_bim"], bim_sub_area["hd_cam_y_bim"] + bim_sub_area["hd_cam_h_bim"],), (0, 0, 255), 40) - - # 在bim上画出高清识别对应的件号 for bim_rect_hit_item in bim_rect_hit_list: bim_rect = bim_rect_hit_item["bim_rect"] @@ -782,5 +787,16 @@ if __name__ == "__main__": 20) bim_im_resize = cv2.resize(bim_im, (int(bim_im.shape[1] / 6), int(bim_im.shape[0] / 6))) cv2.imshow("bim_im_resize", bim_im_resize) + + image = cv2.imread("data_sub/test_5/wide_image.png") + image_x_min = int(640 * 0.1) # 左边界的裁剪点 + image_x_max = int(640 * (1 - 0.1)) # 右边界的裁剪点 + cropped_image = image[:, image_x_min:image_x_max] + # 展示 + cv2.imshow("cropped_image", cropped_image) + cv2.imshow("image", image) + + + cv2.waitKey(0) # ========== 下面仅仅是测试画效果图 结束 ==========