How an I setup New Frame listener for VideoCaptureElement
bbetter opened this issue · 3 comments
bbetter commented
I need to detect whether qr code is present in each frame of web cam output,
How can i get this callback?
xmedeko commented
Check the NewVideoSample
event.
bbetter commented
Sorry for not responding for a long time, the problem is that i'm out of ideas , it never enters this callback
public QrScannerControl()
{
InitializeComponent();
VideoCapElement.EnableSampleGrabbing = true;
VideoCapElement.NewVideoSample += (sender, args) =>
{
var binBitmap = new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(args.VideoFrame)));
BitMatrix bm = binBitmap.BlackMatrix;
Detector detector = new Detector(bm);
DetectorResult detectorResult = detector.detect();
string retStr = "Found at points ";
foreach (ResultPoint point in detectorResult.Points)
{
retStr += point.ToString() + ", ";
}
Console.WriteLine(retStr);
var result = _qrCodeReader.decode(binBitmap);
if (result == null) return;
OnQrDeoded?.Invoke(result.Text);
};
//how should i make it start entering this callback? the play method way is not working
VideoCapElement.Play();
}