Using JavaCPP bindings for OpenCV 3.1, code written in Scala. The methods are mapped nearly exactly as OpenCV 3.1 in C++. I'm attempting to create an affine transform matrix so I can warp an image using landmarks. However, the getAffineTransform
method fails with the following error:
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)
Here's my code, I have a feeling I'm not properly setting the values of the Mat, but how would I do that?
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)