EnigmaOfTheWorld commited on
Commit
04a893c
β€’
1 Parent(s): 81e1d1d

debugging app.py cctv

Browse files
Files changed (1) hide show
  1. app.py +80 -79
app.py CHANGED
@@ -354,88 +354,88 @@ def check_database(ima):
354
 
355
  ###########################
356
  def video(vid):
357
- print(f'Uploaded video name: {vid.name}')
358
- file = '../../../../..'+vid.name
359
- print(f'file: {file}')
360
- # file = vid
361
- video = cv2.VideoCapture(file)
362
- # video.set(cv2.CAP_PROP_FPS, 10)
363
- if (video.isOpened() == False):
364
- print("Error reading video file")
365
- frame_width = int(video.get(3))
366
- frame_height = int(video.get(4))
367
- size = (frame_width, frame_height)
368
-
369
- # # Below VideoWriter object will create
370
- # # a frame of above defined The output
371
- # # is stored in 'filename.avi' file.
372
- result = cv2.VideoWriter('filename.mp4',
373
- cv2.VideoWriter_fourcc(*'mp4v'),
374
- 10, size)
375
 
376
- while(True):
377
- ret, frame = video.read()
378
- if ret == True:
379
-
380
- rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
381
- faces = faceCascade.detectMultiScale(rgb,
382
- scaleFactor=1.1,
383
- minNeighbors=5,
384
- minSize=(60, 60),
385
- flags=cv2.CASCADE_SCALE_IMAGE)
386
 
387
- # convert the input frame from BGR to RGB
388
 
389
- # the facial embeddings for face in input
390
- encodings = face_recognition.face_encodings(rgb)
391
- names = []
392
- # loop over the facial embeddings incase
393
- # we have multiple embeddings for multiple fcaes
394
- for encoding in encodings:
395
- #Compare encodings with encodings in data["encodings"]
396
- #Matches contain array with boolean values and True for the embeddings it matches closely
397
- #and False for rest
398
- matches = face_recognition.compare_faces(data["encodings"],
399
- encoding)
400
- #set name =inknown if no encoding matches
401
- name = "Unknown"
402
- # check to see if we have found a match
403
- if True in matches:
404
- #Find positions at which we get True and store them
405
- matchedIdxs = [i for (i, b) in enumerate(matches) if b]
406
- counts = {}
407
- # loop over the matched indexes and maintain a count for
408
- # each recognized face face
409
- for i in matchedIdxs:
410
- #Check the names at respective indexes we stored in matchedIdxs
411
- name = data["names"][i]
412
- #increase count for the name we got
413
- counts[name] = counts.get(name, 0) + 1
414
- #set name which has highest count
415
- name = max(counts, key=counts.get)
416
 
417
 
418
- # update the list of names
419
- names.append(name)
420
- # loop over the recognized faces
421
- for ((x, y, w, h), name) in zip(faces, names):
422
- # rescale the face coordinates
423
- # draw the predicted face name on the image
424
- cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
425
- cv2.putText(frame, name, (x, y), cv2.FONT_HERSHEY_SIMPLEX,
426
- 0.75, (0, 255, 0), 2)
427
- result.write(frame)
428
- # cv2_imshow(frame)
429
- if cv2.waitKey(1) & 0xFF == ord('q'):
430
- break
431
-
432
- # Break the loop
433
- else:
434
- break
435
-
436
-
437
- # print("The video was successfully saved")
438
- return 'filename.mp4'
439
 
440
  #################
441
  def generate_prompt(AG,facftop,facfmid,facfbot):
@@ -601,7 +601,8 @@ home""")
601
  with gr.Column():
602
  fil1 = gr.File(type="file")
603
  with gr.Column():
604
- vid2 = gr.Video()
 
605
  hbtn = gr.Button("Video")
606
- hbtn.click(video, inputs=fil1, outputs=vid2)
607
  demo.launch()
 
354
 
355
  ###########################
356
  def video(vid):
357
+ return f'Uploaded video name: {vid.name}'
358
+ # file = '../../../../..'+vid.name
359
+ # print(f'file: {file}')
360
+ # # file = vid
361
+ # video = cv2.VideoCapture(file)
362
+ # # video.set(cv2.CAP_PROP_FPS, 10)
363
+ # if (video.isOpened() == False):
364
+ # print("Error reading video file")
365
+ # frame_width = int(video.get(3))
366
+ # frame_height = int(video.get(4))
367
+ # size = (frame_width, frame_height)
368
+
369
+ # # # Below VideoWriter object will create
370
+ # # # a frame of above defined The output
371
+ # # # is stored in 'filename.avi' file.
372
+ # result = cv2.VideoWriter('filename.mp4',
373
+ # cv2.VideoWriter_fourcc(*'mp4v'),
374
+ # 10, size)
375
 
376
+ # while(True):
377
+ # ret, frame = video.read()
378
+ # if ret == True:
379
+
380
+ # rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
381
+ # faces = faceCascade.detectMultiScale(rgb,
382
+ # scaleFactor=1.1,
383
+ # minNeighbors=5,
384
+ # minSize=(60, 60),
385
+ # flags=cv2.CASCADE_SCALE_IMAGE)
386
 
387
+ # # convert the input frame from BGR to RGB
388
 
389
+ # # the facial embeddings for face in input
390
+ # encodings = face_recognition.face_encodings(rgb)
391
+ # names = []
392
+ # # loop over the facial embeddings incase
393
+ # # we have multiple embeddings for multiple fcaes
394
+ # for encoding in encodings:
395
+ # #Compare encodings with encodings in data["encodings"]
396
+ # #Matches contain array with boolean values and True for the embeddings it matches closely
397
+ # #and False for rest
398
+ # matches = face_recognition.compare_faces(data["encodings"],
399
+ # encoding)
400
+ # #set name =inknown if no encoding matches
401
+ # name = "Unknown"
402
+ # # check to see if we have found a match
403
+ # if True in matches:
404
+ # #Find positions at which we get True and store them
405
+ # matchedIdxs = [i for (i, b) in enumerate(matches) if b]
406
+ # counts = {}
407
+ # # loop over the matched indexes and maintain a count for
408
+ # # each recognized face face
409
+ # for i in matchedIdxs:
410
+ # #Check the names at respective indexes we stored in matchedIdxs
411
+ # name = data["names"][i]
412
+ # #increase count for the name we got
413
+ # counts[name] = counts.get(name, 0) + 1
414
+ # #set name which has highest count
415
+ # name = max(counts, key=counts.get)
416
 
417
 
418
+ # # update the list of names
419
+ # names.append(name)
420
+ # # loop over the recognized faces
421
+ # for ((x, y, w, h), name) in zip(faces, names):
422
+ # # rescale the face coordinates
423
+ # # draw the predicted face name on the image
424
+ # cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
425
+ # cv2.putText(frame, name, (x, y), cv2.FONT_HERSHEY_SIMPLEX,
426
+ # 0.75, (0, 255, 0), 2)
427
+ # result.write(frame)
428
+ # # cv2_imshow(frame)
429
+ # if cv2.waitKey(1) & 0xFF == ord('q'):
430
+ # break
431
+
432
+ # # Break the loop
433
+ # else:
434
+ # break
435
+
436
+
437
+ # # print("The video was successfully saved")
438
+ # return 'filename.mp4'
439
 
440
  #################
441
  def generate_prompt(AG,facftop,facfmid,facfbot):
 
601
  with gr.Column():
602
  fil1 = gr.File(type="file")
603
  with gr.Column():
604
+ # vid2 = gr.Video()
605
+ video_name = gr.Text(label="Video Upload")
606
  hbtn = gr.Button("Video")
607
+ hbtn.click(video, inputs=fil1, outputs=video_name)
608
  demo.launch()