Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
911 stars 200 forks source link

The input tensor should have dimensions 1 x height x width x 3. Got 1 x 3 x 416 x 416 #364

Closed azazadev closed 1 year ago

azazadev commented 1 year ago

I'm trying to run custom model for label_detector use case on top of CamerAwesome package, but I got this error : The input tensor should have dimensions 1 x height x width x 3. Got 1 x 3 x 416 x 416., null)

the implementation of onImageForAnalysis is

  onImageForAnalysis: (img) => _analyzeImage(img),

  Future _analyzeImage(AnalysisImage img) async {
    final inputImage = img.toInputImage();
    try {

      // probably something to do here to convert image from 1 x 3 x 416 x 416 to  1 x 416 x 416 x 3 
      // but I don't know how !!!
      processImage(inputImage);
    } catch (error) {
      debugPrint("...sending image resulted error $error");
    }
  }

  Future<void> processImage(InputImage inputImage) async {
    if (!_canProcess) return;
    if (_isBusy) return;
    _isBusy = true;
    setState(() {
      _text = '';
    });
    final labels = await _imageLabeler.processImage(inputImage);
    print(labels.toString());
    _isBusy = false;
    if (mounted) {
      setState(() {});
    }
  }

I know that this is not related to CamerAwesome but any pointer will be appreciated

azazadev commented 1 year ago

issue on model, nothing related to this package, will close ticket