我正在做一个图像处理项目.我需要从一个varible(cv_image <bgr_pixel>)到另一个变量(cv_image <bgr_pixel>)中提取一个感兴趣的区域dlib::rectangle varible
在OpenCV中,它像:
Mat mainImage=cv::imread(location,0);
Mat roi = mainImage(cv::Rect(0,0,100,100))
Run Code Online (Sandbox Code Playgroud)
在Dlib中有没有类似的方法?
我正在尝试使用DLIB的face_landmark_detection_ex.cpp在Visual Studio中构建C++应用程序.构建应用程序从命令promt运行,经过训练的模型和映像文件作为参数传递.
face_landmark_detection_ex.exe shape_predictor_68_face_landmarks.dat image.jpg
Run Code Online (Sandbox Code Playgroud)
这 shape_predictor_68_face_landmarks.dat是68个地标的训练模型,用于对输入图像执行检测,并且每次都需要在运行时加载以执行任何检测.我正在尝试做以下事情.
有没有办法在我的应用程序中打包此文件,以便运行更少的物理内存.
更新:
如何将此shape_predictor_68_face_landmarks.dat文件存储在静态缓冲区中,以便每次shape_predictor都可以从此缓冲区读取.
对于 dlib,我完全是菜鸟。我知道如何直接从文件加载面部形状模型并且它有效。
dlib::shape_predictor face_shape_predictor_;
dlib::deserialize("shape_predictor_68_face_landmarks.dat") >> face_shape_predictor_;
Run Code Online (Sandbox Code Playgroud)
但是如何从 istream 反序列化?
我有以下代码:
dlib::shape_predictor face_shape_predictor_;
std::stringstream face_data_stream;
loadDataToStream(face_data_stream);
dlib::deserialize(face_shape_predictor_, face_data_stream);
Run Code Online (Sandbox Code Playgroud)
我不知道如何让它发挥作用。
我试图将dlib正面探测器中的五级级联拆分为三级(前视,前视但向左旋转,前视但向右旋转)
Evgeniy建议用C++拆分探测器.我不熟悉C++.当我查看frontal_face_detector.h时,get_serialized_frontal_faces返回一个base64编码对象.
我学会了如何将现有的探测器保存到.svm文件中:
#include <dlib/image_processing/frontal_face_detector.h>
#include <iostream>
using namespace dlib;
using namespace std;
int main()
{
frontal_face_detector detector = get_frontal_face_detector();
dlib::serialize("new_detector.svm") << detector;
std::cout<<"End of the Program"<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
那么如何拆分级联并将新探测器保存到.svm文件中?
通过将frontal_face_detector.h中的金字塔等级从<6>降低到较低值,检测器性能也会提高吗?
我试图使用python的dlib库来检测面部标志。我正在使用面部检测器上给出的示例。在安装dlib之前,我已经安装了所有依赖项。
首先,我使用上面链接中给出的“ sudo apt-get install libboost-python-dev cmake”安装了cmake和libboost。然后,我使用“ pip install dlib”安装了dlib。
我的代码:
import sys
import os
import dlib
import glob
from skimage import io
predictor_path = 'shape_predictor_68_face_landmarks.dat'
faces_folder_path = './happy'
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
win = dlib.image_window()
for f in glob.glob(os.path.join(faces_folder_path, "*.jpg")):
print("Processing file: {}".format(f))
img = io.imread(f)
win.clear_overlay()
win.set_image(img)
# Ask the detector to find the bounding boxes of each face. The 1 in the
# second argument indicates that we should upsample the image 1 …Run Code Online (Sandbox Code Playgroud) 我试图imutils.face_utils通过将 OpenCV 矩形转换为 Dlib 的矩形,在使用 Dlibs进行人脸识别之前对齐人脸。但我一直保持错误矩形不可迭代。这是代码
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
fa = FaceAligner(predictor)
Run Code Online (Sandbox Code Playgroud)
如何首先使用 Dlib FaceUtils 进行对齐,然后使用 OpenCV 进行预测recognizer.predict()?
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = detector(gray, 2)
# If faces are found, try to recognize them
for (x,y,w,h) in faces:
(x1, y1, w1, h1) = rect_to_bb(x,y,w,h)
faceAligned = fa.align(image, gray, (x1,y1,w1,h1))
label, confidence = recognizer.predict(faceAligned)
if confidence < threshold:
found_faces.append((label, confidence, (x, y, w, h)))
return found_faces
Run Code Online (Sandbox Code Playgroud) 我正在尝试用 cuda 编译 dlib。我从此 GitHub 链接https://github.com/davisking/dlib克隆存储库,然后尝试运行
python setup.py install --yes USE_AVX_INSTRUCTIONS
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误。任何人都可以帮我解决它吗?
我正在尝试将 dlib 安装到我的 python 虚拟环境中。
这里有一个非常相似的问题,我按照确切的步骤进行操作,但没有成功。
不知何故,我能够在运行代码时导入 dlib ,并且我设法通过 git cloning 来做到这一点git clone -b pybind11 https://github.com/supervacuus/dlib.git。
但是当我尝试安装它pip3 install dlib或依赖于它的库(例如pip3 install face_recognition )时,我收到错误消息,指出ERROR: Failed Building Wheel for dlib
完整的执行日志和错误在这里https://gist.github.com/GhettoBurger996/1e6a423b88b7435c8759255e19fa5e60
我使用的是 3.5.2 和 Ubuntu 16.04
我收到错误:symbol not found in flat namespace '_png_do_expand_palette_rgb8_neon'
尽管dlib已安装相关 Python 版本的包,但仍会发生错误。
我正在使用 VSCode,以防相关。
我是新手,很难解决这个问题。
我想做的是使用网络摄像头运行Face_recognition的示例代码。这两个示例都不适用于我,并且不断抛出此错误。
Traceback (most recent call last):
File "C:\Users\...\Desktop\face_recognition\demo_webcam.py", line 55, in <module>
face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Local\Programs\Python\Python311\Lib\site-packages\face_recognition\api.py", line 214, in face_encodings
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Local\Programs\Python\Python311\Lib\site-packages\face_recognition\api.py", line 214, in <listcomp>
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: compute_face_descriptor(): incompatible function arguments. The following argument types are supported:
1. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], face: _dlib_pybind11.full_object_detection, num_jitters: int = 0, padding: float = 0.25) -> _dlib_pybind11.vector
2. (self: …Run Code Online (Sandbox Code Playgroud)