c++ - Creating 360° VR panorama using OpenCv's SphericalWarper -
i'm using gear360 camera samsung capture pictures , videos. want use files create full 360° panorama can viewed in streetview-esque style. code looks this:
mat cameramatrix = mat::eye(3, 3, cv_32f); mat distcoeffs = mat::zeros(8, 1, cv_32f); mat rvecs = mat::zeros(3, 3, cv_32f); mat tvecs = mat::zeros(3, 3, cv_32f); filestorage fs("conf.xml", filestorage::read); fs["cameramatrix"] >> cameramatrix; fs["distortioncoefficients"] >> distcoeffs; fs["rvecs"] >> rvecs; fs["tvecs"] >> tvecs; fs.release(); mat panorama; mat k = mat::zeros(3, 3, cv_32f); k.at<float>(0, 0) = cameramatrix.at<float>(0, 0); k.at<float>(1, 1) = cameramatrix.at<float>(1, 1); k.at<float>(2, 2) = cameramatrix.at<float>(2, 2); mat r = mat::zeros(3, 3, cv_32f); r.at<float>(0, 0) = rvecs.at<float>(0, 0); r.at<float>(1, 1) = rvecs.at<float>(0, 1); r.at<float>(2, 2) = rvecs.at<float>(0, 2); detail::sphericalwarper warper = detail::sphericalwarper(1.0f); warper.warp(srcimage, k, r, inter_linear, border_default, panorama); imwrite("pano.jpg", panorama); imshow("panorama", panorama);
the xml-file contains coefficients obtained calling calibratecamera()
. use k
, r
because there weird errors when directly using cameramatrix
, rvecs
(opencv claimed size wrong though double checked , should have been ok). anyway, above code compiles generates black image. srcimage
full 360° picture 2 pictures in one. i'm not sure if correct since couldn't find lot of resources regarding topic. if recommend tutorial on how use sphericalwarper in opencv, gladly take @ it.
Comments
Post a Comment