예제 #1
0
def read_image_from_pipe(p, prevcnt=-1):
    if len(select.select([p], [], [], 5.9)[0]) == 0:
        print('got None!!')
        return None, -1
    data = os.read(p, sx * sy * 3)
    if data:
        img = np.fromstring(data, 'uint8').reshape([sy, sx, 3])
        fmt_cnt = image_enc_dec.decode(img)
        if fmt_cnt is None:
            fmt_cnt = prevcnt + 1
    else:
        #print('Error no data')
        return None, -1
    return img, fmt_cnt
예제 #2
0
                                    -1)
                else:
                    if get_files_fds()[0] is not None:
                        print('done recording...')
                        set_files_fds([None, None])
                        data_file_fd = None

                if data_file_fd is not None:
                    pickle.dump([topic, data], data_file_fd, -1)
                    #pickle.dump([b'viewer_data',{'rcv_cnt':rcv_cnt}],data_file_fd,-1)

        #print('-1-',main_data)

        if config.camera_setup == 'stereo':
            if images[0] is not None and images[1] is not None:
                fmt_cnt_l = image_enc_dec.decode(images[0])
                fmt_cnt_r = image_enc_dec.decode(images[1])
                draw_seperate(images[0], images[1], message_dict)
                #join[:,0:sx,:]=images[0]
                #join[:,sx:,:]=images[1]
                join[bmargy // 2:-bmargy // 2,
                     bmargx:sx + bmargx, :] = images[0]
                join[bmargy // 2:-bmargy // 2, sx + bmargx:, :] = images[1]
                images = [None, None]
                draw(join, message_dict, fmt_cnt_l, fmt_cnt_r)
        else:
            join = None
            if images[0] is not None:
                images[0] = cv2.cvtColor(images[0], cv2.COLOR_BGR2RGB)
                fmt_cnt_l = image_enc_dec.decode(images[0])
                draw_mono(images[0], message_dict, fmt_cnt_l)