Skip to content

Commit

Permalink
add: end of video handel
Browse files Browse the repository at this point in the history
  • Loading branch information
YongWookHa committed Jan 21, 2019
1 parent 404be58 commit e95a4ec
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions generate_train_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ def run():
paused = False
delay = {True: 0, False: 1}
count = 0
wasted = 0
print("Entering main Loop.")

datum = op.Datum()

while True:
try:
_, frame = cap.read()

if frame is None:
break
except Exception as e:
print("Failed to grab", e)
break
Expand All @@ -50,23 +52,22 @@ def run():

if persons is None:
print("No Person")
wasted+=1
continue
try:
if persons is not None and len(persons) > 1:
print("Person > 1 ", persons[0].shape)
wasted+=1
continue
except TypeError:
wasted+=1
continue

gray = cv2.cvtColor(datum.cvOutputData-datum.cvInputData, cv2.COLOR_RGB2GRAY)
ret, binary = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY)
cv2.imshow("OpenPose result", binary)
count += 1
print(count)
#if count < 155 or (count > 855 and count < 1255) or (count > 1745 and count < 1775) or (count > 2225 and count < 2265) or (count > 2535 and count < 2915):
# continue
#if count > 2405:
# break
print("count : ", count, " / ","wasted : ", wasted)
cv2.imwrite("original/{}.png".format(count), datum.cvOutputData)
cv2.imwrite("landmarks/{}.png".format(count), binary)

Expand All @@ -85,6 +86,4 @@ def run():
os.makedirs(os.path.join('./', 'original'))
if not os.path.exists(os.path.join('./', 'landmarks')):
os.makedirs(os.path.join('./', 'landmarks'))
# os.makedirs('original', exist_ok=True)
# os.makedirs('landmarks', exist_ok=True)
run()

0 comments on commit e95a4ec

Please sign in to comment.