@@ -497,9 +497,10 @@ class QRCodeDetector extends CvStruct<cvg.QRCodeDetector> {
497497 }) {
498498 final code = straightCode? .ptr ?? calloc< cvg.Mat > ();
499499 final points = calloc< cvg.VecPoint > ();
500- final v = calloc< cvg. VecChar > ();
500+ final v = calloc< ffi. Pointer <ffi. Char > > ();
501501 cvRun (() => CFFI .QRCodeDetector_DetectAndDecode (ref, img.ref, points, code, v));
502- final s = v == ffi.nullptr ? "" : VecChar .fromPointer (v).toString ();
502+ final s = v == ffi.nullptr ? "" : v.value.cast <Utf8 >().toDartString ();
503+ calloc.free (v);
503504 return (s, VecPoint .fromPointer (points), Mat .fromPointer (code));
504505 }
505506
@@ -525,14 +526,13 @@ class QRCodeDetector extends CvStruct<cvg.QRCodeDetector> {
525526 VecPoint ? points,
526527 Mat ? straightCode,
527528 }) {
528- return cvRunArena< (String , VecPoint ? , Mat ? )> ((arena) {
529- points ?? = VecPoint ();
530- final ret = VecChar ();
531- straightCode ?? = Mat .empty ();
532- cvRun (
533- () => CFFI .QRCodeDetector_Decode (ref, img.ref, points! .ref, straightCode! .ref, ret.ptr));
534- return (ret.toString (), points, straightCode! );
535- });
529+ final p = points? .ptr ?? calloc< cvg.VecPoint > ();
530+ final ret = calloc< ffi.Pointer <ffi.Char >> ();
531+ straightCode ?? = Mat .empty ();
532+ cvRun (() => CFFI .QRCodeDetector_Decode (ref, img.ref, p, straightCode! .ref, ret));
533+ final info = ret.value.cast <Utf8 >().toDartString ();
534+ calloc.free (ret);
535+ return (info, VecPoint .fromPointer (p), straightCode);
536536 }
537537
538538 /// Detects QR codes in image and finds of the quadrangles containing the codes.
@@ -542,12 +542,12 @@ class QRCodeDetector extends CvStruct<cvg.QRCodeDetector> {
542542 /// For usage please see TestQRCodeDetector
543543 /// For further details, please see:
544544 /// https://docs.opencv.org/master/de/dc3/classcv_1_1QRCodeDetector.html#aaf2b6b2115b8e8fbc9acf3a8f68872b6
545- (bool , VecPoint ? points) detectMulti (InputArray img, {VecPoint ? points}) {
546- return cvRunArena< (bool , VecPoint ? )> ((arena) {
547- points ?? = VecPoint . fromList ([] );
545+ (bool , VecPoint points) detectMulti (InputArray img, {VecPoint ? points}) {
546+ return cvRunArena< (bool , VecPoint )> ((arena) {
547+ final p = points? .ptr ?? calloc < cvg. VecPoint > ( );
548548 final ret = arena< ffi.Bool > ();
549- cvRun (() => CFFI .QRCodeDetector_DetectMulti (ref, img.ref, points ! .ref , ret));
550- return ret.value ? (ret.value, VecPoint .fromVec (points ! .ref)) : (ret.value, null );
549+ cvRun (() => CFFI .QRCodeDetector_DetectMulti (ref, img.ref, p , ret));
550+ return (ret.value, VecPoint .fromPointer (p) );
551551 });
552552 }
553553
0 commit comments