2017-06-02 137 views
2

使用Android Camera2時,我想在計算曝光時使用區域忽略圖像的前25%。我正在使用這個:Android Camera2 - CONTROL_AE_REGIONS無法在三星設備上工作

// Compute the metering rectangle to ignore the top 25% of the picture: 
Rect newRect = new Rect(mActiveArraySize.left, (int) (mActiveArraySize.height() * 0.25), mActiveArraySize.right, mActiveArraySize.bottom); 
MeteringRectangle meteringRectangle = new MeteringRectangle(newRect, 1); 
MeteringRectangle[] meteringRectangleArr = { meteringRectangle }; 

// Set the metering rectangle: 
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, meteringRectangleArr); 

// Set the request: 
try { mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), null, mBackgroundHandler); } 
catch (CameraAccessException e) { e.printStackTrace(); } 

它在使用我的Nexus 5X。但是在三星Galaxy Note 5上(我想所有的三星設備)都不起作用,我的區域被忽略了。

我看到了這樣一個問題:Android Camera2 API - Set AE-regions not working,這位同事說他設法通過使用三星SDK來實現它。我真的希望避免這種情況。

有人設法讓AE區域與三星設備一起工作嗎?

+0

我有同樣的問題。順便說一句,你是否設置了CONTROL_AE_PRECAPTURE_TRIGGER,CONTROL_AE_MODE,CONTROL_AE_LOCK參數中的任何一個? – Mikhail

回答

0

最近我有同樣的問題,並最終找到了一個解決方案,幫助我。

我所需要做的就是從活動傳感器矩形的邊緣步進1個像素。在你的榜樣,而不是這個矩形:由於有源陣列的botommost像素mActiveArraySize.height() - 1

Rect newRect = new Rect(mActiveArraySize.left + 1, 
         (int)(mActiveArraySize.height() * 0.25), 
         mActiveArraySize.right + 1, 
         mActiveArraySize.bottom - 2); 

我減去2從底部的,我需要減去:

Rect newRect = new Rect(mActiveArraySize.left, 
         (int) (mActiveArraySize.height() * 0.25), 
         mActiveArraySize.right, 
         mActiveArraySize.bottom); 

我會用這多一個像素。

似乎很多廠商已經執行不力的documentation

這部分當測量區域外使用android.scaler.cropRegion在捕捉結果返回的元數據,相機設備將忽略外的部分裁剪區域並僅輸出交集矩形作爲結果元數據中的測量區域。如果該區域完全位於裁剪區域之外,它將被忽略,並且不會在結果元數據中報告。

+0

非常感謝,我會盡力並接受你的答案,如果它適合我!您可能節省了我數週的時間來實施三星的SDK ... –

相關問題