Trying to get the OPenCV for Unity asset to do simple blob detection on a web cam image. The examples all work great - but I can’t get it working on my own. Hoping someone has done some work with this asset and might now the problem.
This is my Update method - the blobDetector has been created in Start like so():
blobDetector = FeatureDetector.create(FeatureDetector.SIMPLEBLOB);
blobDetector.read(Utils.getFilePath("blobparams.yml"));
void Update()
{
if (webCamTextureToMatHelper.isPlaying() && webCamTextureToMatHelper.didUpdateThisFrame())
{
webCamMat = webCamTextureToMatHelper.GetMat();
Mat outImgMat = new Mat();
MatOfKeyPoint keypoints = new MatOfKeyPoint();
blobDetector.detect(webCamMat, keypoints);
Features2d.drawKeypoints(webCamMat, keypoints, outImgMat);
Texture2D texture = new Texture2D(outImgMat.cols(), outImgMat.rows(), TextureFormat.RGBA32, false);
Utils.matToTexture2D(outImgMat, texture);
gameObject.GetComponent<Renderer>().material.mainTexture = webCamTextureToMatHelper.GetWebCamTexture();
}
}
The problem is that keypoints has a size of 0x0 after the blobDetector.detect runs. I guess it’s not finding any blobs… but it should so I must be doing something wrong.