xmax = xmax + col * stride
                                ymax = ymax + row * stride

                                xmin, ymin, xmax, ymax = transform_coord(
                                    xmin, ymin, xmax, ymax, height, width,
                                    each_trans)

                                updated_metric_box.append(
                                    [xmin, ymin, xmax, ymax])

                            boxes += updated_metric_box
                            scores += metric_scores

                np_boxes = np.array(boxes)
                np_scores = np.array(scores)
                boxes, scores = non_max_suppression_fast(
                    np_boxes, 0.75, np_scores)
                metric_json[file_name]['boxes'] = boxes
                metric_json[file_name]['scores'] = scores

                [
                    cv2.rectangle(gt_box_img, (xmin, ymin), (xmax, ymax),
                                  (0, 0, 0), 5)
                    for xmin, ymin, xmax, ymax in boxes
                ]
                # cv2.namedWindow('win',cv2.WINDOW_NORMAL)
                # cv2.imshow('win',gt_box_img)
                # cv2.waitKey(0)
                # cv2.destroyAllWindows()
                cv2.imwrite(os.path.join(result_path, file_name), gt_box_img)

            with open(predicted_json_path, 'w') as f:
Exemple #2
0
                        # print (metric_json)
                        # print (output_dict['detection_boxes'])
                        # print (output_dict['detection_classes'])
                        # print (output_dict['detection_scores'])

                        # print ("Plot")
                        # Plot Image
                        # img_cv2_bgr = cv2.cvtColor(image_np,cv2.COLOR_RGB2BGR)
                        # cv2.imwrite(detection_out_path + str(count) + '.jpg',img_cv2_bgr)
                        # count += 1
                        # whole_img
                        # cv2.imshow('win',img_cv2_bgr)
                        # cv2.waitKey(0)
                        # cv2.destroyAllWindows()

                boxes, scores = non_max_suppression_fast(
                    np.array(boxes), 0.75, np.array(scores))

                [
                    cv2.rectangle(whole_img, (xmin, ymin), (xmax, ymax),
                                  (0, 255, 0), 3)
                    for xmin, ymin, xmax, ymax in boxes
                ]

                print("File_name:{},No.of boxes:{}".format(
                    file_name, len(boxes)))

                metric_json[file_name]['boxes'] = boxes
                metric_json[file_name]['scores'] = scores
                yellow_cell_img_path = os.path.join(image_yellow_path,
                                                    file_name).replace(
                                                        '.bmp', '.jpg')