[英]Can Mobile Vision API's Face Tracking, not Detection, used independent of its CameraSource?
[英]Get Bitmap from Mobile vision's face tracking camera
我正在嘗試從移動視覺的面部跟蹤攝像頭獲取位圖,但是經過大約5個小時的嘗試,我有點卡住了。
I.首先,結果:空白圖片
Bitmap image = mSurfaceView.getDrawingCache().
我已經在這里為SetDrawingCache設置了true:
public CameraSourcePreview(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mStartRequested = false;
mSurfaceAvailable = false;
mSurfaceView = new SurfaceView(context);
mSurfaceView.getHolder().addCallback(new SurfaceCallback());
//HERE
mSurfaceView.setDrawingCacheEnabled(true);
addView(mSurfaceView);
}
II。 之后,我嘗試了以下操作:拍攝Graphic OVerlay的屏幕截圖,並從相機中拍攝照片,然后合並這兩個位圖->結果:糟糕。 一切需要做對的事情都是錯的。
如果有人可以提出任何解決方案(甚至建議都可以),我將不勝感激。
泉。
經過8小時的嘗試。 我得到此解決方法。
首先,我在人臉追蹤相機中獲得了X和Y的疊加屏幕截圖:
overlay = screenShot(mGraphicOverlay);
final float overlayX = mGraphicOverlay.getX();
final float overlayY = mGraphicOverlay.getY();
然后我從相機拍張照片。 調整覆蓋圖的大小以適合相機的圖像。 之后,我將那些2合並為1位圖。 並將其發送回主要活動。
mCameraSource.takePicture(null, new CameraSource.PictureCallback(){
@Override
public void onPictureTaken(byte[] bytes) {
//Bitmap loadedImage = null;
loaded = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
Bitmap rotatedBitmap = null;
Matrix rotateMatrix = new Matrix();
rotateMatrix.postRotate(90);
rotatedBitmap = Bitmap.createBitmap(loaded, 0, 0,
loaded.getWidth(), loaded.getHeight(),
rotateMatrix, false);
overlay = resize(overlay,rotatedBitmap.getWidth(), rotatedBitmap.getHeight());
merged = MergeBitmap(rotatedBitmap, overlay, overlayX, overlayY);
Intent myIntentA1A2 = new Intent(context, MainActivity.class);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
merged.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream .toByteArray();
String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
//imgDecodableString = BitMapToString(GlobalResource.glass);
myIntentA1A2.putExtra("Image", encoded);
context.startActivity(myIntentA1A2);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.