Imread (argv [1], cv_load_image_color) in opencv4 reports an error
view the imread() function description. The second parameter
enum ImreadModes {
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image.
IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
};
Change the second parameter to imread_Grayscale is enough.
The second method:
Add header file:
#include <opencv2/imgcodecs/legacy/constants_c.h>
At this time, the parameter CV_LOAD_IMAGE_Color will not report an error.
Read More:
- [Solved] Opencv Calls PB Model Error: cv2.error: OpenCV(4.2.0)…
- Python draw error: ValueError: ‘color’ kwarg must be a color or sequence of color specs. For a sequence of values to b
- [Solved] OpenCV Error: AttributeError: module ‘cv2‘ has no attribute ‘data‘
- [Solved] Opencv Error: Error: Assertion failed (data) in cv::Mat::at, file … mat.inl.hpp, line 897(Accessed pixels of non-existent matrix)
- [Solved] AttributeError: module ‘keras.preprocessing.image‘ has no attribute ‘load_img‘
- [Solved] OpenCV error: #error “This header with legacy C API declarations has been removed from OpenCV.
- [Solved] Cmake compile opencv open-source project Error: but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be…
- [Solved] Opencv3. X fatal error: opencv2/nonfree/nonfree.hpp: there is no such file or directory
- [Solved] Module ‘scipy.misc‘ has no attribute ‘imread‘
- mainfest Image Error: (img/icons/andriod-chrome-192×192.png)Download error or resource isn’t a vaild image
- Opencv Can not Find opencv2/gpu/gpu.hpp [How to Solve]
- [Solved] Docker Delete Image Error: Error: No such image
- Seaborn Color ValueError: Invalid RGBA argument: [‘#f9802d‘, ‘#f26b15‘, ‘#fdc48f‘]
- [system] [error] Attempted to start Color camera – NOT detected
- Crop the cropper image .toBlob() error: $(“#image”).cropper(‘getCroppedCanvas’).toBlob( function (blob){})
- error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow‘
- How to Solve Opencv Error: CPP: 1557 error
- [Solved] error: ‘CV_GRAY2BGR’ was not declared in this scope
- [Solved] GDAL+OPENCV often reports errors when processing remote sensing impacts
- Cv2.dnn read model error [How to Solve]