1 | initial version |
I've got the same problem with cv2.imshow()
. I found a solution by modifying the data type, and imshow()
can now read the file : answer with source code
2 | No.2 Revision |
I've got the same problem with cv2.imshow()
. I found a solution by modifying the data type, and imshow()
can now read the file : answer with source code
import numpy as np
import cv2
imgL = cv2.imread('tsukuba_l.png', 0)
imgR = cv2.imread('tsukuba_r.png', 0)
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL, imgR, cv2.CV_32F)
norm_coeff = 255 / disparity.max()
cv2.namedWindow("disparity_tsukuba", 0)
cv2.imshow('disparity_tsukuba', disparity*norm_coeff/255)
cv2.waitKey(0)
The problem is indeed that imshow()
can only read CV_8U file when some functions like StereoBM
or other produce CV_32F file : doc
So we need to convert from a CV_32F to a readable format for imshow()
3 | No.3 Revision |
I've got the same problem with cv2.imshow()
. I found a solution by modifying the data type, and imshow()
can now read the file :
import numpy as np
import cv2
imgL = cv2.imread('tsukuba_l.png', 0)
imgR = cv2.imread('tsukuba_r.png', 0)
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL, imgR, cv2.CV_32F)
norm_coeff = 255 / disparity.max()
cv2.namedWindow("disparity_tsukuba", 0)
cv2.imshow('disparity_tsukuba', disparity*norm_coeff/255)
cv2.waitKey(0)
The problem is indeed that imshow()
can only read CV_8U file when some functions like StereoBM
or other produce CV_32F file : doc .
So we need to convert from a CV_32F to a readable format for imshow()
4 | No.4 Revision |
I've got the same problem with cv2.imshow()
. I found a solution by modifying the data type, and imshow()
can now read the file :
import numpy as np
import cv2
imgL = cv2.imread('tsukuba_l.png', 0)
imgR = cv2.imread('tsukuba_r.png', 0)
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL, imgR, cv2.CV_32F)
norm_coeff = 255 / disparity.max()
cv2.namedWindow("disparity_tsukuba", 0)
cv2.imshow('disparity_tsukuba', disparity*norm_coeff/255)
disparity/norm_coeff)
cv2.waitKey(0)
The problem is indeed that imshow()
can only read CV_8U file when some functions like StereoBM
or other produce CV_32F file : doc.
So we need to convert from a CV_32F to a readable format for imshow()
5 | No.5 Revision |
I've got the same problem with cv2.imshow()
. I found a solution by modifying the data type, and imshow()
can now read the file :
import numpy as np
import cv2
imgL = cv2.imread('tsukuba_l.png', 0)
imgR = cv2.imread('tsukuba_r.png', 0)
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL, imgR, cv2.CV_32F)
norm_coeff = disparity.max()
cv2.namedWindow("disparity_tsukuba", 0)
res = cv2.convertScaleAbs(disparity)
cv2.imshow('disparity_tsukuba', disparity/norm_coeff)
res)
cv2.waitKey(0)
The problem is indeed that imshow()
can only read CV_8U file when some functions like StereoBM
or other produce CV_32F file : doc.
So we need to convert from a CV_32F to a readable format for imshow()
6 | No.6 Revision |
I've got the same problem with cv2.imshow()
. I found a solution by modifying the data type, and imshow()
can now read the file :
import numpy as np
import cv2
imgL = cv2.imread('tsukuba_l.png', 0)
imgR = cv2.imread('tsukuba_r.png', 0)
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL, imgR, cv2.CV_32F)
cv2.namedWindow("disparity_tsukuba", 0)
res = cv2.convertScaleAbs(disparity)
cv2.imshow('disparity_tsukuba', res)
cv2.waitKey(0)
The problem is indeed that imshow()
can only read works badly with files other than CV_8U file and can result in wrong image (like all gray images) when given 32F
file, which are produced by some functions like StereoBM
or other produce CV_32F file : doc.
So we need to convert from a CV_32F to a readable format for imshow()
7 | No.7 Revision |
I've got the same problem with cv2.imshow()
. I found a solution by modifying the data type, and imshow()
can now read the file :
import numpy as np
import cv2
imgL = cv2.imread('tsukuba_l.png', 0)
imgR = cv2.imread('tsukuba_r.png', 0)
stereo = cv2.createStereoBM(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL, imgR, cv2.CV_32F)
cv2.namedWindow("disparity_tsukuba", 0)
res = cv2.convertScaleAbs(disparity)
cv2.imshow('disparity_tsukuba', res)
cv2.waitKey(0)
The problem is indeed that imshow()
works badly with files other than CV_8U file and can result in wrong image (like all gray images) when given 32F
file, which are produced by some functions like StereoBM
or other produce CV_32F file : doc.
So we need to convert from a CV_32F to a readable format for imshow()