Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Imglab轮廓是否使用dlib预测图像的准确形状?_Python_Opencv_Image Processing - Fatal编程技术网

Python Imglab轮廓是否使用dlib预测图像的准确形状?

Python Imglab轮廓是否使用dlib预测图像的准确形状?,python,opencv,image-processing,Python,Opencv,Image Processing,Iam目前正在开发一种使用dlib进行精确地标预测的形状预测器。我使用并创建了一个用于输入形状预测的svm检测器进行训练。上面的链接是针对人脸的,但这里输入的图像是衣服。我用图像测试了它,得到了输出,但不一致。 我将在这里附上我使用imglab创建的注释和测试结果 我用于测试的代码是 def rect_to_bb(rect): x = rect.left() y = rect.top() w = rect.right() - x h = rect.botto

Iam目前正在开发一种使用dlib进行精确地标预测的形状预测器。我使用并创建了一个用于输入形状预测的svm检测器进行训练。上面的链接是针对人脸的,但这里输入的图像是衣服。我用图像测试了它,得到了输出,但不一致。 我将在这里附上我使用imglab创建的注释和测试结果

我用于测试的代码是

def rect_to_bb(rect):

    x = rect.left()
    y = rect.top()
    w = rect.right() - x
    h = rect.bottom() - y

    # return a tuple of (x, y, w, h)
    return (x, y, w, h)
def shape_to_np(shape, dtype="int"):
    import numpy as np
    # initialize the list of (x, y)-coordinates
    coords = np.zeros((shape.num_parts, 2), dtype=dtype)

    # loop over all facial landmarks and convert them
    # to a 2-tuple of (x, y)-coordinates
    for i in range(0, shape.num_parts):
        coords[i] = (shape.part(i).x, shape.part(i).y)

    # return the list of (x, y)-coordinates
    return coords

# import imutils
import dlib
import cv2
import imutils
import argparse

# Now let's use the detector as you would in a normal application.  First we
# will load it from disk.
ap = argparse.ArgumentParser()
ap.add_argument("-p", "--shape-predictor", required=True,
    help="path to facial landmark predictor")
args = vars(ap.parse_args())
detector = dlib.simple_object_detector("detector.svm")
predictor = dlib.shape_predictor(args["shape_predictor"])

# Video capture source

# We can look at the HOG filter we learned.  It should look like a face.  Neat!
win_det = dlib.image_window()
win_det.set_image(detector)

win = dlib.image_window()

image = cv2.imread("/home/sharon/Documents/orbec/Working/01-04-2020/dress_model_d-lib_imlab/dataset/6.png")
image = imutils.resize(image, width=800)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


rects = detector(gray)

# loop over the face detections
for rect in rects:
    # convert the dlib rectangle into an OpenCV bounding box and
    # draw a bounding box surrounding the face
    (x, y, w, h) = rect_to_bb(rect)
    cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
    # use our custom dlib shape predictor to predict the location
    # of our landmark coordinates, then convert the prediction to
    # an easily parsable NumPy array
    shape = predictor(gray, rect)
    shape = shape_to_np(shape)
    # loop over the (x, y)-coordinates from our dlib shape
    # predictor model draw them on the image
    for (sX, sY) in shape:
        cv2.circle(image, (sX, sY), 1, (0, 0, 255), -1)
    # show the frame
    cv2.imshow("Frame", image)
    cv2.waitKey(0)
    # key = cv2.waitKey(1) & 0xFF
    # # if the `q` key was pressed, break from the loop
    # if key == ord("q"):
    #   break
# do a bit of cleanup
cv2.destroyAllWindows()
    
# vs.stop()
给定输入图像的注释文件为

version: 1
n_points:  47
{
409 196
431 252
499 288
571 253
584 196
634 214
671 226
700 250
725 282
751 307
781 343
763 363
743 378
718 405
695 412
724 745
704 444
703 480
704 520
709 559
712 598
718 643
722 685
266 744
356 216
316 228
295 252
272 279
241 306
208 337
236 361
254 379
280 409
293 408
290 445
287 483
284 523
280 558
278 595
277 648
269 690
307 745
349 741
416 739
485 736
566 735
638 732
}
请建议我在哪里失去我的流量