Comments (4)
Could you show me your code? The possible cause is that the value range should be 0-255.We've done some post-processing on the images.Please carefully find the relevant code in the project.
from hms-ml-demo.
@SoftwareGift thank you for your comment, please let me explain the whole scenario, because there's no way to record the video (record what happen inside LensEnginePreview
), I tried to capture the view and converting it to Bitmap, every second I pass the bitmap to MediaRecorder
in order to generate a video file.
The issue, is related to the Bitmap inside GraphicOverlay
, I don't know why but when I try to convert the LensEnginePreview
to Bitmap
The image loses its width.
Regarding the code : I've tried to use the same code in the Gesture-Change-Background and the same issue happened.
View to Bitmap (Using Kotlin KTX) :
fun view2Bitmap(lens: LensEnginePreview): Bitmap {
return lens.drawToBitmap()
}
View to Bitmap :
public static Bitmap view2Bitmap(final View view) {
if (view == null) return null;
boolean drawingCacheEnabled = view.isDrawingCacheEnabled();
boolean willNotCacheDrawing = view.willNotCacheDrawing();
view.setDrawingCacheEnabled(true);
view.setWillNotCacheDrawing(false);
Bitmap drawingCache = view.getDrawingCache();
Bitmap bitmap;
if (null == drawingCache || drawingCache.isRecycled()) {
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
drawingCache = view.getDrawingCache();
if (null == drawingCache || drawingCache.isRecycled()) {
bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
} else {
bitmap = Bitmap.createBitmap(drawingCache);
}
} else {
bitmap = Bitmap.createBitmap(drawingCache);
}
view.setWillNotCacheDrawing(willNotCacheDrawing);
view.setDrawingCacheEnabled(drawingCacheEnabled);
return bitmap;
}
please use one of the above code in the Gesture-Change-Background project, and you will see what I'm talking about.
Thank you
from hms-ml-demo.
The pixel value of the image ranges from 0 to 255. You can write the bitmap value to a txt file and see if the value is the same as you expected.
from hms-ml-demo.
I've managed to fix this issue, thank you
from hms-ml-demo.
Related Issues (20)
- MLCnIcrCaptureResult
- Is this compatible in Google Play Store? HOT 2
- LivenessCustomDetectionActivity 摄像头预览变形 HOT 2
- 关于Face2D-Sticker的问题 HOT 2
- Face2D-Sticker在手机上运行闪退 HOT 3
- Is there any possibility to record the video with diffrent background (HMS ML Image Segmentation)
- Liveness detection camera facing back HOT 3
- Why the VideoView inside LensEnginePreview is always Stretched HOT 1
- Black Image When setExact is FALSE
- Removing the background from a video takes a long time to finish
- App crash when updating to 3.0.0.301 HOT 1
- Hair Segmentation Not working HOT 1
- ML Body 闪退 HOT 7
- IDEA打开引入ApplicationCases后运行报错 HOT 1
- Incomplete README.md HOT 2
- The liveness Camera View not able make as full screen HOT 1
- Hello I am using ML kit Document skew correction and it is crashing on android 9 only HOT 3
- 早上好
- 音源分离端侧报错
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hms-ml-demo.