cv2.imread flags not found

前端 未结 2 903
甜味超标
甜味超标 2020-12-09 03:28

I recently started working with openCV and python and decided to analyze some sample code to get an idea of how things are done.

However, the sample code I found, ke

2条回答
  •  有刺的猬
    2020-12-09 04:13

    have you tried this?

    import cv2
    import sys
    import numpy as np
    
    
    cv2.CV_LOAD_IMAGE_COLOR = 1 # set flag to 1 to give colour image
    #cv2.CV_LOAD_IMAGE_COLOR = 0 # set flag to 0 to give a grayscale one
    
    
    img = cv2.imread("link_to_your_file/file.jpg", cv2.CV_LOAD_IMAGE_COLOR) 
    
    
    cv2.namedWindow('Display Window') ## create window for display
    cv2.imshow('Display Window', img) ## Show image in the window
    print ("size of image: "), img.shape ## print size of image
    cv2.waitKey(0) ## Wait for keystroke
    cv2.destroyAllWindows() ## Destroy all windows
    

    see imread also have a look at this

提交回复
热议问题