I found that every time I use the opencv package to process remote sensing images, it often reports an error, even though it has become uint format.
This time I found out that some of them only support three channels, my binary image is one channel, the error of storing the result is because I need to save the result of 1 channel, mine is three channels
so it is necessary to convert 1 channel to 3 channels back and forth ` img1 = np.array(b1)
# img2 = np.dtype(img1, np.uint8)
img = np.expand_dims(img1, axis=2)
img = np.concatenate((img, img, img), axis=-1)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
contours, hierarchy = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# contours = cv2.findContours(img)
dilate = cv2.fillPoly(img, [contours[1]],(255,15,15))
cv2.imshow("filled binary", dilate)`
Read More:
- [Solved] Cmake compile opencv open-source project Error: but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be…
- How to Solve Opencv Error: CPP: 1557 error
- [Solved] Opencv error: assertion__acrt_first_block == header
- Scanf_S always reports errors [How to Solve]
- IDEA reports an error Could not reserve enough space for xxxxKB object heap processing
- [Solved] Unity3d reports an error using the opencv plug-in: unsafe code may only appear if compiling with/unsafe.
- WPF path = (validation. Errors) [0]. Errorcontent reports a binding error
- [Solved] Opencv3. X fatal error: opencv2/nonfree/nonfree.hpp: there is no such file or directory
- [Solved] Opencv Calls PB Model Error: cv2.error: OpenCV(4.2.0)…
- Opencv Can not Find opencv2/gpu/gpu.hpp [How to Solve]
- [Solved] OpenCV error: #error “This header with legacy C API declarations has been removed from OpenCV.
- [Solved] Remote URL test failed: Could not read from remote repository.
- Git push Submit to Remote Error: “remote: Support for password authentication was removed on August 13, 2021.“
- OpenCV4 Error: imread(argv[1], CV_LOAD_IMAGE_COLOR);
- Eclipse start project error: Errors occurred during the build. Errors running builder ‘Integrated External Tool Builder’ on…
- OpenCV VideoWriter Failed to Start [How to Solve]
- [Solved] ORB_SLAM3 Compile Error: opencv4.0 not found four
- CMake Error: The source directory “opencv Install Catalog“ does not appear to contain CMakeLists.txt.
- [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)