def check_current_folder(self, current_set):

        self.current_set = current_set
        print('==> Checking {}'.format(current_set))
        print(
            magenta(
                '1: D5 / 2: P20 / 3: ZED_rgb / 4: ZED_depth / 5:ZED_confidence'
            ))

        self.get_images_in_current_set(current_set)
        self.show_images('1')
        while True:
            key = cv2.waitKey()
            if self.zed_depth_exist:
                if chr(key) not in ['1', '2', '3', '4', '5']:
                    print(red('Pressed key is {}'.format(chr(key))))
                    break
            else:
                if chr(key) not in ['1', '2', '3']:
                    print(red('Pressed key is {}'.format(chr(key))))
                    break

            cv2.destroyAllWindows()
            self.show_images(chr(key))

        return key
    def check_images(self):
        self.print_helpping_messages()
        # Check if there is folder need to be inspectedssss
        if len(self.set_list) == 0:
            print(red('No sets to inspect - please check the folder'))
            return -1

        set_pointer = self.set_list[-1]

        while True:
            print(len(self.set_list))
            # Check if there is folder need to be inspectedssss
            if len(self.set_list) == 0:
                print(red('No more sets to inspect '))
                break

            new_key = self.check_current_folder(set_pointer)

            current_set_index = self.set_list.index(self.current_set)
            if chr(new_key) == 'n':
                if current_set_index < len(self.set_list) - 1:
                    set_pointer = self.set_list[current_set_index + 1]
                else:
                    print(red('This set is the end of the list'))

            elif chr(new_key) == 'p':
                if current_set_index > 0:
                    set_pointer = self.set_list[current_set_index - 1]
                else:
                    print(red('This set is the first of the list'))

            elif chr(new_key) in ['s', 'h', 'd']:
                set_pointer = self.move_items_accordingly(new_key)

            elif chr(new_key) == 'q':
                print('Exiting the program')
                break

            else:
                print(red('[!]Please press the right key'))
                self.print_helpping_messages()
                        default=False,
                        help="When indicated, ZED will run.")
    args = parser.parse_args()

    __ADJUST_TIME__ = args.zed_rest
    processes = []
    if args.zed:
        processes.append('zed')
    if args.p20:
        processes.append('p20')
    if args.d5:
        processes.append('D5')

    if len(processes) == 0:
        print(
            red('[Error] Select at least one device to run: --p20 / --zed / --d5'
                ))
        exit(-1)

    print(cyan('============== Selected Devices ================'))
    print(cyan('{}'.format(processes)))
    print(cyan('==================== Guide ====================='))
    print(cyan('Mouse LEFT click to record videos.'))
    print(cyan('Mouse RIGHT click to exit the program.'))

    make_dir_if_not_exists(__ZED_IMG_PATH__)
    make_dir_if_not_exists(__P20_IMG_PATH__)
    make_dir_if_not_exists(__D5_IMG_PATH__)

    # Create logger
    img_logger = logutils.create_logger(__VID_LOGGING_FILE__)
        "--mode",
        type=str,
        help="Which dataset that you want to sort out. [IMG | VID]")
    parser.add_argument('--set_continue',
                        default=0,
                        type=int,
                        help='Continue to create the set from this number.')
    parser.add_argument('--convertSVO', action='store_true')
    args = parser.parse_args()

    date = args.date
    mode = args.mode
    set_count = args.set_continue

    if mode != 'IMG' and mode != 'VID':
        print(red('Please choose the mode between [ IMG | VID ]'))
        exit(-1)

    if mode == 'VID':
        __INPUT_DIR__ = './saved_data/VID/{}/'.format(date)
        __LOG_FILE__ = './saved_data/VID/{}/video_capture.log'.format(date)
        __OUTPUT_DIR__ = './saved_data/VID/{}/sorted'.format(date)

        #
        # # list is in [D5, P20, ZED] order
        # list_vid_dir = logutils.read_log_file(__LOG_FILE__, __INPUT_DIR__, is_video=True)
        #
        # put_videos_pairs_in_folder(list_vid_dir, __OUTPUT_DIR__, set_count)
        #
        # if args.convertSVO:
        #     make_svo2avi(__OUTPUT_DIR__)
Esempio n. 5
0
import os
import cv2
from utils.print_utils import yellow, red

__BASE_DIR__ = '/media/dc2019/My Book/VID/VQM_data'
__TEST_DIR__ = os.path.join(__BASE_DIR__, 'zed/test')
__VALID_DIR__ = os.path.join(__BASE_DIR__, 'zed/validation')

sets = os.listdir(__TEST_DIR__)

for set in sets:
    set_dir = os.path.join(__TEST_DIR__, set)
    print(yellow(set_dir))
    frames = os.listdir(set_dir)
    for frame in frames:
        print(os.path.join(set_dir, frame))
        try:
            img = cv2.imread(os.path.join(set_dir, frame))
        except:
            print(red(os.path.join(set_dir, frame)))

print('Done!')
    parser.add_argument("--d5", action="store_true", default=False, help="When indicated, Canon D5 Mark IV will run.")
    parser.add_argument("--zed", action="store_true", default=False, help="When indicated, ZED will run.")
    args = parser.parse_args()

    __VID_TIME__ = args.vid_time
    __ADJUST_TIME__ = args.zed_rest
    processes = []
    if args.zed:
        processes.append('zed')
    if args.p20:
        processes.append('p20')
    if args.d5:
        processes.append('D5')

    if len(processes) == 0:
        print(red('Select at least one device to run: --p20 / --zed / --d5'))
        exit(-1)

    print(cyan('============== Selected Devices ================'))
    print(cyan('{}'.format(processes)))
    print(cyan('==================== Guide ====================='))
    print(cyan('Mouse LEFT click to record videos.'))
    print(cyan('Mouse RIGHT click to exit the program.'))


    make_dir_if_not_exists(__ZED_VID_PATH__)
    make_dir_if_not_exists(__P20_VID_PATH__)
    make_dir_if_not_exists(__D5_VID_PATH__)

    # Create logger
    vid_logger = logutils.create_logger(__VID_LOGGING_FILE__)