-1

I am doing gender and emotion classification using python programming and I want to save results in sqlite databases...A piece of code is following: text2 = emotion_mode + " " + gender_mode

    tstmp = datetime.datetime.now().strftime("%S")
    date = str(datetime.datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M:%S'))

    fps.update()
    fps.stop()
    t = fps.elapsed()
    if text2 == last_row1:
       continue
    else:
       last_row1 = text2
    c.execute("INSERT INTO users (gender,emotion,time,start,end) VALUES (?,?,?,?,?)" ,(gender_mode,emotion_mode,date,t,t1))
    conn.commit()

bgr_image = cv2.cvtColor(rgb_image, cv2.COLOR_RGB2BGR)
cv2.imshow('window_frame', bgr_image)
if cv2.waitKey(1) & 0xFF == ord('q'):
    break

emotion_mode and gender_mode is for example (angry man and etc...) I want to get t and t1 :t=time that start angry man and t1:time that end angry man and so on...

Cœur
  • 37,241
  • 25
  • 195
  • 267
roik sail
  • 9
  • 6

1 Answers1

0

If you just want to get the time between two events, you can use time.

based on this answer from Mike Lewis:

import time
time1 = time.time()
waitForAngryMenToGetHappy()
time2 = time.time()
print('took %0.3f ms' %((time2-time1)*1000.0))
Skandix
  • 1,916
  • 6
  • 27
  • 36
  • no i want to count frames that for example angry man occured.,(how insert in code?) – roik sail Feb 05 '18 at 13:46
  • could you provide an example, what you want your output to look like? – Skandix Feb 05 '18 at 13:53
  • Yes...i want to when gender/emotion detected then save time of occurence saved..i have this that it is datetime.datetime.now in code..but i have'nt difference of between two situation (for example angry man and happy man) that whats time elapsed angry man occuranced. – roik sail Feb 05 '18 at 14:19
  • @roiksail: sorry, I can't follow that - could you bring up an example? – Skandix Feb 07 '18 at 09:26