fixed merge conflict

This commit is contained in:
Nickiel12 2023-10-12 21:17:07 -07:00
parent e35245cd8c
commit 43d36335a6
12 changed files with 12124 additions and 12135 deletions

View file

@ -83,7 +83,7 @@ if args.file:
cap = cv2.VideoCapture(args.file) cap = cv2.VideoCapture(args.file)
else: else:
cap = cv2.VideoCapture(0, cv2.IMREAD_GRAYSCALE) # instead of grayscale you can also use -1, 0, or 1. cap = cv2.VideoCapture(0, cv2.IMREAD_GRAYSCALE) # instead of grayscale you can also use -1, 0, or 1.
faceCascade = cv2.CascadeClassifier(r"./cascades/cascade_5.xml") # CHECK THIS FIRST TROUBLE SHOOTING faceCascade = cv2.CascadeClassifier(r"./cascades/cascade_10.xml") # CHECK THIS FIRST TROUBLE SHOOTING
datestamp = "{:%Y_%m_%d %H_%M_%S}".format(datetime.datetime.now()) datestamp = "{:%Y_%m_%d %H_%M_%S}".format(datetime.datetime.now())
output_dir = r"./output/" + datestamp + r"/" output_dir = r"./output/" + datestamp + r"/"

View file

@ -1,25 +0,0 @@
NixOS/Nix:
If you run on a Nix or NixOS environment, you can use the included shell.nix file to create a nix shell to run this in.
Windows/Other Linux:
This program was developed with python 3.11, so please use that version of python to create the virtual environment. After making sure you are using the correct python version, run the following commands:
python -m venv venv
to create a new virtual environment ".\venv"
now enter the the virtual environment by running either .\venv\Scripts\Activate.ps1 or ./venv/Scripts/activate depending on if you use windows and install the following packages (found in requirements.txt)
pip install numpy
pip install opencv-python
Now you can run the program. It is recommended to run the program with -d and -o set while testing. This enables the dashboard which shows live statistics, and output, which shows the calculated adjustments required to center the face in the frame.
Training Data:
https://www.kaggle.com/datasets/utkarshsaxenadn/landscape-recognition-image-dataset-12k-images
create positives from the negatives: \opencv\build\x64\vc15\bin\opencv_createsamples.exe -img .\positives\face_1.png -bg .\bg.txt -info info/info.lst -pngoutput info -maxxangle 0.8 -maxyangle 0.8 -maxzangle 0.8 -num 1950
Create vec files from positives: .\opencv\build\x64\vc15\bin\opencv_createsamples.exe -info .\info\info.lst -num 1950 -w 80 -h 80 -vec positives-80.vec
(I created a 20, 40, and 80) we have 1650 positives

View file

@ -22,6 +22,9 @@ def init_argparse() -> argparse.ArgumentParser:
parser.add_argument( parser.add_argument(
"out_file", help="the file to write the output to" "out_file", help="the file to write the output to"
) )
parser.add_argument(
"-f", "--faces_count_file", help="the file output the number of faces found in each frame"
)
return parser return parser
multiplication_factor = 0.05 multiplication_factor = 0.05
@ -71,6 +74,13 @@ for test_fb in test_results:
def bring_up_gt(): def bring_up_gt():
if test_fb.frame_number > ground_truth[0].frame_number: if test_fb.frame_number > ground_truth[0].frame_number:
ground_truth.pop(0) ground_truth.pop(0)
if test_fb.frame_number > ground_truth[0].frame_number:
# we need to include the empty frames too
if args.faces_count_file:
with open(args.faces_count_file, 'a') as out_file:
out_file.write(f"{ground_truth[0].frame_number}, 0,\n")
bring_up_gt() bring_up_gt()
bring_up_gt() bring_up_gt()
@ -81,9 +91,13 @@ for test_fb in test_results:
gt_adjustment = get_adjustment_amount((1920, 1000), gt_frame.top_left[0], gt_frame.top_left[1], gt_frame.bottom_right[0], gt_frame.bottom_right[1]) gt_adjustment = get_adjustment_amount((1920, 1000), gt_frame.top_left[0], gt_frame.top_left[1], gt_frame.bottom_right[0], gt_frame.bottom_right[1])
test_adjustment = get_adjustment_amount((1920, 1000), test_fb.top_left[0], test_fb.top_left[1], test_fb.bottom_right[0], test_fb.bottom_right[1]) test_adjustment = get_adjustment_amount((1920, 1000), test_fb.top_left[0], test_fb.top_left[1], test_fb.bottom_right[0], test_fb.bottom_right[1])
if last_frame_num != test_fb.frame_number and average_count != 0: if last_frame_num != test_fb.frame_number :
with open(args.out_file, 'a') as out_file: if average_count > 0:
out_file.write(f"{average_sum},\n") with open(args.out_file, 'a') as out_file:
out_file.write(f"{average_sum},\n")
if args.faces_count_file:
with open(args.faces_count_file, 'a') as out_file:
out_file.write(f"{test_fb.frame_number}, {average_count},\n")
average_sum = 0 average_sum = 0
average_count = 0 average_count = 0