Exemple #1
0
def show_inference(model, image_path):
    image_np = np.array(image_path)
    lane_image = copy.deepcopy(image_np)
    height, width, channel = image_np.shape

    output_dict = functions.get_dict(dashPointer, model, image_np)

    confidencesCars, boxesCars, confidencesLights, boxesLights, confidencesPersons, boxesPersons = functions.findBoxes(
        image_np, output_dict)

    indexesLights = cv2.dnn.NMSBoxes(boxesLights, confidencesLights, 0.5, 0.4)
    indexesCars = cv2.dnn.NMSBoxes(boxesCars, confidencesCars, 0.5, 0.4)
    indexesPersons = cv2.dnn.NMSBoxes(boxesPersons, confidencesPersons, 0.5,
                                      0.4)

    image_np = signalDetection_utils.signalDetection(indexesLights,
                                                     boxesLights, image_np)
    image_np = tracking_utils.tracking(indexesCars, boxesCars, image_np)
    image_np = estimate_collide_utils.estimate_collide(indexesCars, boxesCars,
                                                       image_np)
    image_np = estimate_stepping_utils.estimate_stepping(
        indexesPersons, boxesPersons, image_np)

    cv2.putText(image_np, "DAY", (width - 200, 50), font, 2, (167, 133, 0), 2,
                cv2.LINE_AA)

    image_np = lane_detection_utils.draw_lines(lanePointer, lane_image,
                                               image_np)
    # lane_detection_utils.all_lines(lanePointer , lane_image , image_np)

    cv2.imshow("finally", image_np)
def show_inference(dashPointer, lanePointer, frame):
    global flagPerson, areaPerson, areaDetails
    global crash_count_frames
    global signalCounter, flagSignal
    global prev_frame, number
    global flagLanes

    image_np = np.array(frame)
    lane_image = copy.deepcopy(image_np)
    height, width, channel = image_np.shape

    output_dict = functions.get_dict(dashPointer, detection_model, image_np)

    confidencesCars, boxesCars, confidencesLights, boxesLights, confidencesPersons, boxesPersons = functions.findBoxes(
        image_np, output_dict)

    indexesLights = cv2.dnn.NMSBoxes(boxesLights, confidencesLights, 0.5, 0.4)
    indexesCars = cv2.dnn.NMSBoxes(boxesCars, confidencesCars, 0.5, 0.4)
    indexesPersons = cv2.dnn.NMSBoxes(boxesPersons, confidencesPersons, 0.5,
                                      0.4)

    image_np, signalCounter, flagSignal = signalDetection_utils.signalDetection(
        indexesLights, boxesLights, image_np, signalCounter, flagSignal)
    image_np, prev_frame, number = tracking_utils.tracking(
        indexesCars, boxesCars, image_np, prev_frame, number)
    image_np, crash_count_frames = estimate_collide_utils.estimate_collide(
        indexesCars, boxesCars, image_np, crash_count_frames)
    image_np, flagPerson, areaPerson, areaDetails = estimate_stepping_utils.estimate_stepping(
        indexesPersons, boxesPersons, image_np, flagPerson, areaPerson,
        areaDetails)

    cv2.putText(image_np, "DAY", (50, 90), font, 2, (167, 133, 0), 2,
                cv2.LINE_AA)

    image_np, flagLanes = lane_detection_utils.draw_lines(
        lanePointer, dashPointer, lane_image, image_np, flagLanes)
    # lane_detection_utils.all_lines(lanePointer , lane_image , image_np)

    cv2.imshow("Final result", image_np)