Giter Club home page Giter Club logo

opencv-python-series's Introduction

opencv-python-series's People

Contributors

acgoliyan avatar codingforentrepreneurs avatar jmitchel3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencv-python-series's Issues

timelapse project

I am trying to build timlapses off of the code used to capture and compile a timelapse. I wave deleted the code for capturing images as I simply want to use images take with my personal camera. I have also done my best (I'm very new to this) to remove references to other code files like the utils.py file. I wanted this to be a simple and stand alone code for my sake. As far as I can tell, it works. it pulls all the files I want and creates a video, the problem is that the video is extremely choppy and isn't much better running at lower resolution. this is what I've got.

`import os
import numpy as np
import cv2
import time
import datetime

import glob

#Vairables
frames_per_second = 24
save_path='saved-media/timelapse.mp4'

out = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), frames_per_second, (1620, 1080))
timelapse_img_dir = r'E:\Nature\Sky captures\2021-10-19_Timelapse_PythonFJPG'

clear_images = False

def images_to_video(out, timelapse_image_dir, clear_images=False):
image_list = glob.glob(f"{timelapse_image_dir}/*.JPG")
sorted_images = sorted(image_list, key=os.path.getmtime)

for file in sorted_images:
    ImageToVideoFrames = cv2.imread(file)
    out.write(ImageToVideoFrames)
return (0)

images_to_video(out, timelapse_img_dir)
out.release()
cv2.destroyAllWindows()
print ('complete')`

cv2.cv2' has no attribute 'face'

Hello @codingforentrepreneurs ,
I am using the same code as of yours and when I run it it shows me the following
capture

Here is the code
`import cv2
import os
import numpy as np
from PIL import Image
import pickle

BASE_DIR = os.path.dirname(os.path.abspath(file))
image_dir = os.path.join(BASE_DIR, "images")

face_cascade = cv2.CascadeClassifier('cascades/data/haarcascade_frontalface_alt2.xml')
recognizer = cv2.face.LBPHFaceRecognizer_create()

current_id = 0
label_ids = {}
y_labels =[]
x_train = []

for root, dirs, files in os.walk(image_dir):
for file in files:
if file.endswith(".png") or file.endswith(".jpg"):
path = os.path.join(root, file)
label = os.path.basename(os.path.dirname(path)).replace(" ", "-"). lower()
#print(label, path)
if not label in label_ids:
label_ids[label] = current_id
current_id +=1
id_ = label_ids[label]

		pil_image = Image.open(path).convert("L")
		image_array = np.array(pil_image, "uint8")
		#print(image_array)
		faces = face_cascade.detectMultiScale(image_array, scaleFactor=1.5, minNeighbors=5)
		for (x,y,w,h) in faces:
			roi = image_array[y:y+h, x:x+w]
			x_train.append(roi)
			y_labels.append(id)

with open("labels.pickle", 'wb') as f:
pickle.dump(label_ids, f)

recognizer.train(x_train, np.array(y_labels))
recognizer.save("trainner.yml")`

faces.py

I am getting error
OpenCV Error: Unspecified error (File can't be opened for reading!) in cv::face::FaceRecognizer::read, file C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp, line 61
Traceback (most recent call last):
File "faces.py", line 11, in
recognizer.read("trainner.yml")
cv2.error: C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2) File can't be opened for reading! in function cv::face::FaceRecognizer::read

EOFError: Ran out of input

i have a problem ๐Ÿ˜‚๐Ÿคฃ

labels = {"person_name": 1} with open("labels.pickle", 'rb') as f: og_labels = pickle.load(f) labels = {v:k for k,v in og_labels.items()}

Traceback (most recent call last):
File "FeacID.py", line 11, in
og_labels = pickle.load(f)
EOFError: Ran out of input

how to fix it ? help me please ๐Ÿ˜‚๐Ÿ˜‚๐Ÿ‘จโ€๐Ÿ’ป

python .\faces.py error

Hi guys
I just got all the code and thought i got all the way though the FR stuff but i keep getting a error when i run faces.py

PS C:\Users\ADBY\Desktop\Coding\OpenCV-Python-Series-master\src> python .\faces.py
OpenCV Error: Unspecified error (File can't be opened for reading!) in cv::face::FaceRecognizer::read, file C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp, line 61
Traceback (most recent call last):
File ".\faces.py", line 11, in
recognizer.read("trainner.yml")
cv2.error: C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2) File can't be opened for reading! in function cv::face::FaceRecognizer::read

Error in Face Recognition code

can any one tell me what to do? i am receiving this error. How to resolve it?

recognizer.read('trainer/trainer.yml')
cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read'

cv_face_FaceRecognizer_read erro

Hey guys.
I'm here with this bug in my code and I can't even find a solution for it.
I've already used "load" instead of "read", but still an error appears. When I change the opencv version, I can't create the training "yml" file anymore.
Below is my code with the "yml" file already created.

from PIL import Image
import cv2
import numpy as np
import os

lbph_face_classifier = cv2.face.LBPHFaceRecognizer_create()
lbph_face_classifier.read('/train/lbph_classifier.yml')
imagem_teste = ('C:/Users/MD Francisco/Desktop/Expert/dlib/Reconhecimento/yalefaces/test/subject10.sad.gif')
imagem = Image.open(imagem_teste).convert('L')
imagem_np = np.array('uint8')
print(imagem_np)

Error again

Its showing me an error like this

error
OpenCV Error: Bad argument (This LBPH model is not computed yet. Did you call the train method?) in cv::face::LBPH::predict, file C:\ci\opencv_1512685267089\work\opencv_contrib-3.3.1\modules\face\src\lbph_faces.cpp, line 400
Traceback (most recent call last):
File "faces.py", line 31, in
id_, conf = recognizer.predict(roi_gray)
cv2.error: C:\ci\opencv_1512685267089\work\opencv_contrib-3.3.1\modules\face\src\lbph_faces.cpp:400: error: (-5) This LBPH model is not computed yet. Did you call the train method? in function cv::face::LBPH::predict

ModuleNotFoundError: No module named 'utils'

git clone https://github.com/codingforentrepreneurs/OpenCV-Python-Series
cd OpenCV-Python-Series
pip install -r requirements.txt
python .\src\lessons\watermark_lesson.py

File ".\src\lesson\watermark_lesson.py", line 4, in
from utils import CFEVideoConf, image_resize
ModuleNotFoundError: No module named 'utils'

wrong recognition even after training

Hi,

i retrained the model simply by putting my face images there into images folder with the folder named by name and run the training steps.

But even after changing the model named to the new created model i am setting getting old labels...
in other words, my name is not coming with my face, i think training wasn't successful.

Any solution?
thanks

Is there any assistance needed ?

Hi everyone,
I would love to contribute to this project, however I am not sure if maintainers are still active here ... ๐Ÿค”
Would appreciate your answer.

'cv::face::FaceRecognizer::read'

Traceback (most recent call last):
File "faces.py", line 11, in
recognizer.read("./recognizors/face-trainner.yml")
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read'

Error

OpenCV Error: Bad argument (This LBPH model is not computed yet. Did you call the train method?) in cv::face::LBPH::predict, file C:\ci\opencv_1512685267089\work\opencv_contrib-3.3.1\modules\face\src\lbph_faces.cpp, line 400
Traceback (most recent call last):
File "faces.py", line 31, in
id_, conf = recognizer.predict(roi_gray)
cv2.error: C:\ci\opencv_1512685267089\work\opencv_contrib-3.3.1\modules\face\src\lbph_faces.cpp:400: error: (-5) This LBPH model is not computed yet. Did you call the train method? in function cv::face::LBPH::predict

model.train(np.asarray(Training_Data), np.asarray(Labels)) cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

model.train(np.asarray(Training_Data), np.asarray(Labels))
cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

recognizer.train(x_train, np.array(y_labels)) cv2.error

recognizer.train(x_train, np.array(y_labels))
cv2.error: OpenCV(4.0.1) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

How can I fix it?

TabError: inconsistent use of tabs and spaces in indentation

I was trying to run the code but it resulted in this error.
File "c:/Users/SCT/Desktop/Siddhartha/classified project details/realtime_recog.py", line 35 font = cv2.FONT_HERSHEY_SIMPLEX ^ TabError: inconsistent use of tabs and spaces in indentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.