olexale / arkit_flutter_plugin

ARKit Flutter Plugin
MIT License
796 stars 225 forks source link

Object Detection Throws numerous casting errors #152

Open mrseth01 opened 3 years ago

mrseth01 commented 3 years ago

I'm working with the face detection example, and the onAddNodeForAnchor and onUpdateNodeForAnchor both throw casting errors.

The data coming from ARKit is

{nodeName: AE542996-8220-455C-8BFB-BFB35A80E58D, rightEyeTransform: [0.9995921850204468, 0.0008244996424764395, 0.028543813154101372, 0.0, 0.0, 0.9995830655097961, -0.028873363509774208, 0.0, -0.028555719181895256, 0.02886158786714077, 0.9991754293441772, 0.0, -0.03157740458846092, 0.027242830023169518, 0.025471298024058342, 1.0], transform: [-0.35135069489479065, -0.06945854425430298, -0.9336637258529663, 0.0, 0.14473184943199158, 0.9812269806861877, -0.12746162712574005, 0.0, 0.9249891638755798, -0.17991462349891663, -0.3347019553184509, 0.0, -0.5131411552429199, 0.057212211191654205, 0.064279705286026, 1.0], anchorType: faceAnchor, isTracked: true, identifier: 130C4895-3EA8-4434-82EF-47430493FAF3, leftEyeTransform: [0.9953778386116028, 0.0027611996047198772, 0.09599634259939194, 0.0, 0.0, 0.9995865821838379, -0.02875170111656189, 0.0, -0.09603604674339294, 0.02861880697309971, 0.9949663281440735, 0.0, 0.03157731518149376, 0.027242861688137054, 0.025471264496445656, 1.0], blendShapes: {mouthPress_L: 0.12284887582063675, browDown_R: 0.4861116409301758, eyeLookOut_L: 0.0, eyeSquint_L: 0.2154432088136673, mouthSmile_R: 0.0, mouthUpperUp_R: 0.04221158102154732, mouthClose: 0.06203304976224899, eyeBlink_R: 0.0, mouthFrown_L: 0.02609141357243061, mouthSmile_L: 0.0, jawRight: 0.14295893907546997, mouthStretch_R: 0.10802911221981049, eyeLookOut_R: 0.046752702444791794, mouthRollUpper: 0.04182938113808632, mouthStretch_L: 0.06784066557884216, mouthUpperUp_L: 0.03676971048116684, eyeLookDown_L: 0.0, mouthPress_R: 0.11297580599784851, mouthShrugUpper: 0.3064204752445221, browDown_L: 0.48610204458236694, mouthDimple_R: 0.04411003366112709, eyeBlink_L: 0.0, browInnerUp: 0.034281570464372635, mouthShrugLower: 0.20249131321907043, eyeLookUp_L: 0.06590313464403152, browOuterUp_R: 0.0, mouthFunnel: 0.08159372210502625, cheekSquint_R: 0.07863833755254745, jawForward: 0.04478762298822403, eyeLookDown_R: 0.0, jawLeft: 0.0, mouthRollLower: 0.11560932546854019, noseSneer_L: 0.10995630919933319, eyeWide_R: 0.23248456418514252, cheekSquint_L: 0.08726654946804047, mouthLowerDown_R: 0.06004893034696579, browOuterUp_L: 0.0, cheekPuff: 0.13279126584529877, eyeLookIn_L: 0.15745581686496735, mouthRight: 0.1814725548028946, jawOpen: 0.06203304976224899, mouthLowerDown_L: 0.061507899314165115, eyeSquint_R: 0.21178606152534485, mouthFrown_R: 0.016514809802174568, noseSneer_R: 0.12138834595680237, mouthPucker: 0.27664700150489807, tongueOut: 0.0004885859088972211, eyeLookUp_R: 0.06618207693099976, eyeWide_L: 0.23272772133350372, eyeLookIn_R: 0.0, mouthLeft: 0.0, mouthDimple_L: 0.036158643662929535}}

And since there is no geometry key, the following error is thrown.

flutter: type 'Null' is not a subtype of type 'Map<dynamic, dynamic>'

Also, json_serializable uses the as Map<String, dynamic> notation instead of the Map<String, dynamic>.from() notation which also seems to be a problem.

mrseth01 commented 3 years ago

My project has null safety on, which is probably the issue. The example app runs okay, but the same code adjusted for the obvious null-safety fixes does not work in my project.

olexale commented 3 years ago

Hi! This should be fixed in 1.0.3. You may already try it by using the plugin from the repo, will push a new release to pub.dev soon.