Example #1
0
def detect(signal_queue, key, sensors_queue):
    detector = detection.Detector()
    while True:
        time.sleep(0.001)
        # update sensors data
        while True:
            try:
                (
                    detector.time,
                    # detector.gpsRaw_position,
                    # detector.gpsRaw_speed,
                    detector.compassRaw,
                    detector.camerasRaw), frame = sensors_queue.get(
                        block=True, timeout=0.001)
                timer = time.time()
                detector.process()
                # send all signals except object detection to decider
                signal_queue.put((detector.signals, frame))
                # detectedInfo(' '.join(
                #     ['Detector frame:', str(frame), 'stage1: spend', str(int((time.time() - timer) * 1000)), 'ms']
                # ))
                timer = time.time()
                detector.object_detection()
                # object detection updated
                signal_queue.put((detector.signals, frame))
                # detectedInfo(' '.join(
                #     ['Detector frame:', str(frame), 'stage2: spend', str(int((time.time() - timer) * 1000)), 'ms']
                # ))
            except queue.Empty:
                pass
Example #2
0
 def __init__(self, detector=None, recognizer=None, scale=2, max_size=2048):
     if detector is None:
         detector = detection.Detector()
     if recognizer is None:
         recognizer = recognition.Recognizer()
     self.scale = scale
     self.detector = detector
     self.recognizer = recognizer
     self.max_size = max_size
Example #3
0
import psycopg2
import sys
import detection

conn = psycopg2.connect('dbname=gis user=gis')

run = "iaicoco"
sensitives = ("car", "person", "truck")
cur = conn.cursor()
cur.execute(
    "SELECT id FROM panoramas WHERE authorised=0 AND id >= 9686 ORDER BY id")
results = cur.fetchall()
if (len(results) == 0):
    print("No Results")
else:
    prob = 25
    if (len(sys.argv) > 1):
        prob = int(sys.argv[1])
    detector = detection.Detector(prob, run)
    for result in results:
        detector.detect(result[0])
Example #4
0

def output(img_path, pipe, out_path):
    img_path = img_path[0]
    img = cv2.imread(img_path)
    # img = cv2.resize(img, (img.shape[1] // 2, img.shape[0] // 2))
    predictions = pipe.recognize(images=[img])[0]
    drawn = tools.drawBoxes(
        image=img, boxes=predictions, boxes_format='predictions'
    )
    print(
        'Predicted:', [text for text, box in predictions]
    )
    cv2.imwrite(out_path, drawn)

validation = get_ocr_detector_dataset('test')

generator_kwargs = {'width': 640, 'height': 640}

validation_image_generator = datasets.get_detector_image_generator(
    labels=validation,
    **generator_kwargs
)

detector = detection.Detector()
detector.model.load_weights(f'model/{args.model}.h5')
pipe = pipeline.Pipeline(detector=detector)
for i, img in enumerate(validation):
    print('sdfsdf')
    print(img[0])
    output(img, pipe, f'output_{i}.png')