cv2.CreateMat in python
Hi guys
i'm trying to use the cv.CreateMat in a python code but when i run it i got this error:
AttributeError: 'module' object has no attribute 'createMat'!!!!!
Please can anybody help me! thank you
in cv2, everything's a numpy array. ( it does not need any Create* functions anymore. if you ask me - for the better! )
Sorry but i didn't understand you (i'm new in opencv and python) how can i create matrix?!
>>> import numpy as np
>>> a = numpy.array((3,4,3), np.uint8) # (that is: height, width,numchannels)
(i'm going to try a more detailled answer tomorrow ... )
okay thank you so much (please if you can help me in cv.stereoCalibration, how to calculate R,T,F,E?i'll be thankful) waiting for your explanation tomorrow.
use cv2.stereoCalibrate - it will just return all of them.
in general, stick to the cv2 api. the old cv one won't be included in the next release
ok,i did it and it works now thank you one more question please what will the next step be in order to be able to calculate the distance between the tow webcams and the object in front of them?
have a look at StereoBM or StereoSGBM to create a disparity map, which is (inverse)proportional to the distance. maybe this sample is helpful
okay working on it thank you
hi again, i tried to run the cv2.stereoRectify but i got this error:
Traceback (most recent call last): File "C:\opencv246\samples\python2\stereocalib.py", line 132, in <module> cv.stereoRectify(camera_matrixL, cameraR_matrix, dist_coefsL, dist_coefsR,(384,288), R, T, RL, Rr, PL, PR) error: ......\src\opencv\modules\imgproc\src\undistort.cpp:292: error: (-215) CV_IS_MAT(_distCoeffs) && (_distCoeffs->rows == 1 || _distCoeffs->cols == 1) && (_distCoeffs->rows_distCoeffs->cols == 4 || _distCoeffs->rows_distCoeffs->cols == 5 || _distCoeffs->rows*_distCoeffs->cols == 8) why?!
please use: cv2.stereoRectify(cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, image, ...
imho, you used the cv one, and mixed up the arguments
python has a nice help function, btw:
>>> import cv2
>>> help(cv2.stereoRectify)
Help on built-in function stereoRectify in module cv2:
stereoRectify(...) stereoRectify(cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, imageS ize, R, T[, R1[, R2[, P1[, P2[, Q[, flags[, alpha[, newImageSize]]]]]]]]) -> R1, R2, P1, P2, Q, validPixROI1, validPixROI2