0
使用用於OpenCV 3.1的JavaCPP綁定,使用Scala編寫的代碼。這些方法幾乎與C++中的OpenCV 3.1一致。我正在嘗試創建仿射變換矩陣,以便使用地標可以對圖像進行變形。然而,getAffineTransform
方法失敗,出現以下錯誤:如何爲仿射變換創建一個形狀爲[3,2]的OpenCV Mat?
java.lang.RuntimeException: /Users/saudet/projects/bytedeco/javacpp-presets/opencv/cppbuild/macosx-x86_64/opencv-3.1.0/modules/imgproc/src/imgwarp.cpp:6360:
error: (-215) src.checkVector(2, CV_32F) == 3 && dst.checkVector(2, CV_32F) == 3 in function getAffineTransform
at org.bytedeco.javacpp.opencv_imgproc.getAffineTransform(flandmarkTest.sc0.tmp)
at #worksheet#.H$lzycompute(flandmarkTest.sc0.tmp:82)
at #worksheet#.H(flandmarkTest.sc0.tmp:82)
at #worksheet#.get$$instance$$H(flandmarkTest.sc0.tmp:82)
at #worksheet#.#worksheet#(flandmarkTest.sc0.tmp:236)
這裏是我的代碼,我有一種感覺,我沒有正確設置墊的值,但我會怎麼做呢?
val landmarkM = new Mat()
landmarkM.put(new Scalar(outerEyeLeft(0),outerEyeLeft(1)))
landmarkM.put(new Scalar(outerEyeRight(0),outerEyeRight(1)))
landmarkM.put(new Scalar(nose(0),nose(1)))
val imgDim = img_grayscale.width()
val refM = new Mat()
refM.put(new Scalar(template(1)(0)*imgDim,template(1)(1)*imgDim))
refM.put(new Scalar(template(4)(0)*imgDim,template(4)(1)*imgDim))
refM.put(new Scalar(template(5)(0)*imgDim,template(5)(1)*imgDim))
refM.checkVector(2) // returns -1
landmarkM.checkVector(2) // returns -1
val H: Mat = getAffineTransform(landmarkM, refM)