Android bgra camera feed to object detection

Assuming that the cascade is loaded with another plugin call earlier, the rawImage has a snapshot from a BGRA camera feed in Android, should this code work with lbp cascade files? Or am I doing something horribly wrong? (I ask because this native plugin code is not detecting anything in OpenCV 4.5.3. although I have confirmed that the rawImage is populating with what it needs to, and it’s running the code – just finding nothing / adding nothing to the referenced image count).

Mat image(height, width, CV_8UC4, *rawImage);
	std::vector<Rect> faces;
	Mat grayscaleFrame;
	cvtColor(image, grayscaleFrame, COLOR_BGRA2GRAY);
	
	Mat resizedGray;
	resize(grayscaleFrame, resizedGray, Size(image.cols / _scale, image.rows / _scale));
	equalizeHist(resizedGray, resizedGray);
	_faceCascade.detectMultiScale(resizedGray, faces);

those cascades are ancient tech and very rigid. they will NOT detect faces that are slightly rotated/tilted.

run samples/python/facedetect.py with a bogus camera ID to get it to load the well known lena picture. it’ll detect that.

then use lena in your own code. check that the code works.

1 Like

Thanks, that’s good information to have — I have not looked into the rabbit hole of training my own cascades yet but I’ll note that. Was just testing the existing samples first. Are there any other more recent samples available or is every xml file as old as it looks on the GitHub repo?