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
947 stars 234 forks source link

Display AnalysisImage #208

Closed CaoGiaHieu-dev closed 5 months ago

CaoGiaHieu-dev commented 1 year ago

Hi ,I try to display AnalysisImage when listen on onImageForAnalysis . But i can not found any document about this.

istornz commented 1 year ago

Hello @CaoGiaHieu-dev, you can check the official documentation.

You can also check our examples 👍

CaoGiaHieu-dev commented 1 year ago

Hello @CaoGiaHieu-dev, you can check the official documentation.

You can also check our examples 👍

Thanks . But i still cant found any example or doc is tell me how to display AnalysisImage from onImageForAnalysis

istornz commented 1 year ago

In examples, you have a InputImage inputImage object like here.

You can found a Uint8List property inside it: inputImage.bytes, so you can display it like this (for example): Image.memory(Uint8List bytes);

CaoGiaHieu-dev commented 1 year ago

I try to follow your example and display inputImage.bytes but it show this error ════════ Exception caught by image resource service ════════════════════════════ The following _Exception was thrown resolving an image codec: Exception: Invalid image data

When the exception was thrown, this was the stack

0 _futurize (dart:ui/painting.dart:5522:5)

1 ImageDescriptor.encoded (dart:ui/painting.dart:5390:12)

2 instantiateImageCodec (dart:ui/painting.dart:2053:60)

════════════════════════════════════════════════════════════════════════════════
g-apparence commented 1 year ago

If you want to display it you have to use a format jpeg. Or you can convert it before showing it.

CaoGiaHieu-dev commented 1 year ago

If you want to display it you have to use a format jpeg. Or you can convert it before showing it.

Thanks @g-apparence . that all i want . Can you show me an example code . Thank you

apalala-dev commented 1 year ago

I will provide you an example :) Are you on iOS or Android?

CaoGiaHieu-dev commented 1 year ago

I will provide you an example :) Are you on iOS or Android?

im want to show it on android .

apalala-dev commented 1 year ago

It is not as trivial as I though :/ Since the format is not the typical one displayed in a Flutter Image, there is some conversion to do and the best way to do that is to do it on the native side, which involves method channels etc. Can you give use your use case for this? Doing the conversion for each frame in nv21 for analysis and in jpeg for displaying should be quite demanding as well.

CaoGiaHieu-dev commented 1 year ago

im stuck in this issue even i try to call back image from native side like CameraImage of Camera package

apalala-dev commented 1 year ago

I've tried a similar approach but it requires more work and maybe some changes from CamerAwesome for this to work.

Can you explain why you are trying to display the analysis image?

CaoGiaHieu-dev commented 1 year ago

I've tried a similar approach but it requires more work and maybe some changes from CamerAwesome for this to work.

Can you explain why you are trying to display the analysis image?

It more like an ekyc bussiness and i need image of action to verify user.

CaoGiaHieu-dev commented 1 year ago

@apalala-dev Hi . any update on this ?

apalala-dev commented 1 year ago

Hi, not yet sorry. You'll be able to track progress on this in #218.

The idea would be to rework the AnalysisConfig and AnalysisImage. The later one could include both an analysis image (e.g.: NV21 for android) AND a jpeg one if necessary to be able to display it. Some tests need to be done first as it will duplicate the image and treatment for every frame (it might be done every X frames or something like that, not sure yet).

An other option would be to provide a method to convert analysis images (nv21...) to more traditional JPEG. This way, you would have to do it on demand. It might be simpler to implement but less performant.

CaoGiaHieu-dev commented 1 year ago

convert analysis images (nv21...) to more traditional JPEG

i found this https://github.com/google-ar/sceneform-android-sdk/issues/965 and the AwesomeCamera was return the nv21 bytes . Could you look around this?

apalala-dev commented 1 year ago

We almost have the technical part (like what you sent) but we need to figure out a good API to use it. If you really need it fast, you can use the sent code and convert the nv21 image with method channels.