import cv2
import os
os.sys.path
from os import listdir
from PIL import Image
from numpy import asarray
from numpy import expand_dims
import pickle
folder="data_test_deteksi"
database = {}
for filename in listdir(folder):
path = folder + filename
gbr1 = cv2.imread(folder + filename)
wajah = HaarCascade.detectMultiScale(gbr1,1.1,4)
if len(wajah)>0:
x1, y1, width, height = wajah[0]
else:
x1, y1, width, height = 1, 1, 10, 10
x1, y1 = abs(x1), abs(y1)
x2, y2 = x1 + width, y1 + height
gbr = cv2.cvtColor(gbr1, cv2.COLOR_BGR2RGB)
gbr = Image.fromarray(gbr) # konversi dari OpenCV ke PIL
gbr_array = asarray(gbr)
face = gbr_array[y1:y2, x1:x2]
face = Image.fromarray(face)
face = face.resize((160,160))
face = asarray(face)
face = face.astype('float32')
mean, std = face.mean(), face.std()
face = (face - mean) / std
face = expand_dims(face, axis=0)
signature = MyFaceNet.predict(face)
database[os.path.splitext(filename)[0]]=signature
Why name 'HaarCascade' is not defined?
226 views Asked by Luky Vianika Sari At
1
There are 1 answers
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in OPENCV
- Creating multiple instances of a class with different initializing values in Flutter
- OpenCV2 on CLion
- How to Draw Chinese Characters on a Picture with OpenCV
- Python cv2 imwrite() - RGB or BGR
- AttributeError: 'Sequential' object has no attribute 'predict_classes'. Did you mean: 'predict_step'?
- Search for an icon on an image OpenCV
- DJI Tello won't follow me
- Python OpenCV and PyGame threading issue
- Need help in Converting Python script (Uses Yolo's pose estimation) to an android app
- Line Segmentation Problem: How to detect lines and draw bounding box of that line on handwritten letters Using CV2
- Configure CmakeLists.txt to avoid manually copying dlls
- How to detect the exact boundary of a Sudoku using OpenCV when there are multiple external boundaries?
- AttributeError: 'Results' object has no attribute 'box'. can anyone explain this?
- How to generate a VPI warpmap for polynomial distortion correction?
- I am trying to make a project of object detection on kaggle notebook using yolo. and i am facing this error. here is my code and my error
Related Questions in JUPYTER
- I am getting 'NoneType object is not subscriptable' error in web scraping method
- Jupyter notebook: " No module named 'google.colab'", after having updated Anaconda
- Jupyter Hub not fiinding my workspace and killing it (version 4.1.13)
- How to call `InteractiveShellEmbed`-based custom excepthook via `jupyter-console --existing`
- RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory when running command to train yolov5 on custom data
- Same python code runs 20 times slower in Jupyter Notebook compared to command line
- How to render more than 1 dialogs on Jupyterlab?
- Jupyter Notebook not rendering report with pandas profiling
- jupyter notebook - Why `tornado.web.HTTPError: HTTP 403: Forbidden`?
- Error when trying to open csv in google colab; Jupyter works well
- Jupyter command `jupyter-bundlerextension` not found
- having issues installing libraries using the 'conda' command after installing anaconda
- When using a jupyter notebook in VSCode, the Python interpreter is ignored
- Unexpected Error with ipynb file in VSCode
- Spacy matcher is not finding any matches for counties
Related Questions in FACE-RECOGNITION
- Way to get CustomPainter to track face in Camera Flutter MLKit
- Face Recognition in Windows Logon
- Should I use the default model in the deepface package or fine-tune it to fit with my data for face recognition?
- How to use Google ML KIT to recognize facial expressions Determine whether a person is smiling or has their eyes closed
- Change Windows Logon
- Issue FaceRecognition
- face_recognition library: TypeError: compute_face_descriptor(): incompatible function arguments
- AttributeError: module 'face_recognition' has no attribute 'face_encodings' if tried to use as REST API
- Is this model overfit or underfit?
- i have install face_recognition_models but it is not importing in vscode and keep saying inytsall face_recognition model consider i am a new mac user
- Bug known when scanning face, the camera spamming take photo and doing flashing on screen on iPhone
- How to execute mqtt commands of Getconfig in android java
- How to handle specs glare in face recognition?
- How to classify facials features embedding with high accuracy(+ 90%). what adjustment can i make in svm model to classify 20+ classes
- Error :"tile cannot extend outside image"
Related Questions in FACENET
- output of pretrained facenet model is [2, 512] instead of [1, 512]
- Tensorflow gradients missing
- Extracting Face Embeddings and Comparing Them Using FaceNet
- How do I get face embedding from face obtained from ML KIT using FaceNet
- Facenet_keras: (ValueError: bad marshal data (unknown type code))
- Running FaceNet in real time for face recognition using openCV and mtcnn
- Error while generating triplets in custom train loop
- How to solve Facenet pytorch Installation issue in kaggle?
- Can I fine-tune a pre-trained model to improve its accuracy for my input data?
- Cv2.error: OpenCV 4.7.0 and overload resolution failed Python 3.x
- Adding labels while converting SVC FaceClassification model to CoreML using, converters.sklearn.convert
- Load facenet model
- Face Recognition issue with mobile facenet
- My Image Data Generator is converting my images to grayscale(from RGB)
- InceptionResnet (vggface2) Pytorch giving incorrect facial predictions
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
There is nothing named as
HaarCascadein opencv, you need to usecv2.CascadeClassifier. First downloadhaarcascadexml file and then pass the path of that file like thisface_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')