Skip to content

Commit

Permalink
sort image pah array
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Jan 23, 2018
1 parent 81bcd14 commit f1a3fb3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions egohands_dataset_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import numpy as np
import os
import gc
import six.moves.urllib as urllib
import cv2
import time
import xml.etree.cElementTree as ET
import random
import shutil as sh
from shutil import copyfile
import zipfile
import six.moves.urllib as urllib

import csv


Expand All @@ -28,6 +29,8 @@ def get_bbox_visualize(base_path, dir):
img_path = base_path + dir + "/" + f
image_path_array.append(img_path)

#sort image_path_array to ensure its in the low to high order expected in polygon.mat
image_path_array.sort()
boxes = sio.loadmat(
base_path + dir + "/polygons.mat")
# there are 100 of these per folder in the egohands dataset
Expand Down Expand Up @@ -198,6 +201,15 @@ def rename_files(image_dir):

generate_csv_files("egohands/_LABELLED_SAMPLES/")

def extract_folder(dataset_path):
print("Egohands dataset already downloaded.\nGenerating CSV files")
if not os.path.exists("egohands"):
zip_ref = zipfile.ZipFile(dataset_path, 'r')
print("> Extracting Dataset files")
zip_ref.extractall("egohands")
print("> Extraction complete")
zip_ref.close()
rename_files("egohands/_LABELLED_SAMPLES/")

def download_egohands_dataset(dataset_url, dataset_path):
is_downloaded = os.path.exists(dataset_path)
Expand All @@ -207,17 +219,10 @@ def download_egohands_dataset(dataset_url, dataset_path):
opener = urllib.request.URLopener()
opener.retrieve(dataset_url, dataset_path)
print("> download complete")
extract_folder(dataset_path);

else:
print("Egohands dataset already downloaded.\nGenerating CSV files")

if not os.path.exists("egohands"):
zip_ref = zipfile.ZipFile(dataset_path, 'r')
print("> Extracting Dataset files")
zip_ref.extractall("egohands")
print("> Extraction complete")
zip_ref.close()
rename_files("egohands/_LABELLED_SAMPLES/")
extract_folder(dataset_path)


EGOHANDS_DATASET_URL = "http://vision.soic.indiana.edu/egohands_files/egohands_data.zip"
Expand Down

0 comments on commit f1a3fb3

Please sign in to comment.