def detect_pre(shared_frame_arrs, shared_trans_arrs): start_time = None frame_id = 0 while True: read_slot = shared_frame_arrs.openReadId() if start_time is None: start_time = time.time() if read_slot is None: break read_arrs = shared_frame_arrs.accessNumpyBuffer(read_slot) frame_id += 1 write_slot = shared_trans_arrs.openWriteId() write_arrs = shared_trans_arrs.accessNumpyBuffer(write_slot) det_preprocess(read_arrs[0], write_arrs[1]) shared_frame_arrs.closeReadId(read_slot) shared_trans_arrs.closeWriteId(write_slot) end_time = time.time() shared_trans_arrs.close() print "Ran", frame_id, "frames" print('detect_preprocessing time: {0} seconds'.format(end_time - start_time))
def detect(runner, fpgaBlobs, image): fpgaInput = fpgaBlobs[0][0] c, h, w = fpgaInput[0].shape szs = det_preprocess(image, w, h, fpgaInput[0]) jid = runner.execute_async(fpgaBlobs[0], fpgaBlobs[1]) runner.wait(jid) rects = det_postprocess(fpgaBlobs[1][1], fpgaBlobs[1][0], [h, w, c], szs) return rects