【问题标题】:how to use cv2.cvtColor function如何使用 cv2.cvtColor 函数
【发布时间】:2020-07-18 11:02:29
【问题描述】:

查看代码 导入简历2 导入操作系统 将 numpy 导入为 np 将 faceRecognition 导入为 fr

test_img=cv2.imread('H:\faceRecognition\TestImages\img.jpg')
    faces_detected,gray_img = fr.faceDetection(test_img)
    print("faces_detected:",faces_detected)

for(x,y,w,h) in faces_detected: 
    cv2.rectangle(test_img,(x,y),(x+w,y+h),(255,0,0),thickness=5)

resized_img=cv2.resized_img(test_img,(1000,700))
cv2.imshow("Face Detection Tutorial",resized_img)
cv2.waitKey(0)
cv2.destroyAllWindows

【问题讨论】:

    标签: python opencv4


    【解决方案1】:
    import cv2
    
    defimg = 'H:\\faceRecognition\\TestImages\\img.jpg'
    outimg = 'H:\\faceRecognition\\TestImages\\output_img.jpg'
    
    common_available_spaces = {
        '8': cv2.CV_8U,       # 8-bit unsigned (0-255)
        '16': cv2.CV_16U,     # 16-bit unsigned (0-65535)
        '32': cv2.CV_32F      # 1 precision floating point (0-1)
    }
    OUTPUT_COLOR_SPACE = common_available_spaces['8']
    
    cv2.cvtColor(src=defimg, code=OUTPUT_COLOR_SPACE, dst=outimg)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-10
      • 2017-06-16
      • 2020-01-21
      • 2014-07-22
      • 2021-09-09
      • 2020-06-26
      相关资源
      最近更新 更多