Hi,
I have observed that on my Samsung tablet the frame I received in Image Analysis is always 800X480 although I have set the targetResolution as 1080X1920. Even if I set the targetResolution to 1920X1080, the frame size is still 800X480. I have checked the supported camera resolutions of the device, and it do supports the resolution I have passed, but it is not picking that up. The frame size I have received is too low resolution to process in my Image Analyser, so I need a bigger frame size.
Can it be due to the aspect ratio? But the device aspect ratio is 1.33*(1024/768), and the native camera captures images in resolution 2592X1944 (1.33), so I would expect the resolution from CameraX in ImageAnalysis to be 1600X1200 (1.33), but it isn't. It is picking the aspect ratio of 5:3 (1.67).
But then how can I get required frame size in CameraX, like in camera2 I can resize the TextureView as per the resolution I need.
I have initialised the fullscreen camera using the below code, which is working fine in the mobile phone.
...
private val targetResolution = Size(1080, 1920)
...
cameraExecutor = Executors.newSingleThreadExecutor()
...
private fun startCamera() {
val cameraProviderFuture = ProcessCameraProvider.getInstance(requireContext())
val cameraSelector =
CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build()
cameraProviderFuture.addListener({
val cameraProvider = cameraProviderFuture.get()
imagePreview = Preview.Builder().apply {
setTargetResolution(targetResolution)
setTargetRotation(binding.previewView.display.rotation)
}.build()
imageAnalysis = ImageAnalysis.Builder().apply {
setTargetResolution(targetResolution)
setTargetRotation(binding.previewView.display.rotation)
setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
}.build().also {
scannerAnalyzer = ScannerAnalyzer(args, this)
it.setAnalyzer(
cameraExecutor, scannerAnalyzer
)
}
cameraProvider.unbindAll()
camera = cameraProvider.bindToLifecycle(
this,
cameraSelector,
imagePreview,
imageAnalysis
)
cameraControl = camera.cameraControl
cameraInfo = camera.cameraInfo
imagePreview.setSurfaceProvider(binding.previewView.surfaceProvider)
setTorchStateObserver()
}, ContextCompat.getMainExecutor(requireContext()))
}
My Device Configuration on which I am facing issue is
Model: SM-P355 (gt5note8ltexx)
Manufacturer: samsung
Dimension: 208.3 x 137.9 x 7.4 mm
Weight: 313 g
Baseband Version: P355XXU1CQI4
RIL Version: Samsung RIL v3.0
Build Number: NMF26X.P355XXS1CTJ1
Build Fingerprint: samsung/gt5note8ltexx/gt5note8lte:7.1.1/NMF26X/P355XXS1CTJ1:user/release-keys
Bootloader: P355XXS1CTJ1
Java VM: ART 2.1.0
OS Version: N MR1 (7.1.1)
SDK: 25
DISPLAY
Size: 8.0 inches
Resolution: 768x1024 pixels
Pixel Density: 160 ppi
Software Density: 210 dpi
Refresh Rate: 60 Hz
PROCESSOR
CPU Architecture: ARMv7 Processor rev 0 (v7l)
Board: MSM8916
Chipset: Qualcomm Technologies, Inc MSM8916
Cores: 4
Clock Speed: 1094 MHz - 1190 MHz
Instruction Sets: armeabi-v7a, armeabi
CPU Features: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 evtstrm
CPU Governor: interactive
Kernel Version: 3.10.49-12366605
Kernel Architecture: armv7l
GRAPHICS
Renderer: Adreno (TM) 306
Vendor: Qualcomm
OpenGL Version: OpenGL ES 3.0
RAM
Total: 1890 MB
Java Heap: 128 MB
STORAGE
Internal: 11 GB
EXTERNAL: Not Detected
PRIMARY CAMERA
Resolution: 5 MP
Flash: No
Video Resolution: HD, 1280x720
Supported Resolutions:
Image:
2592x1944
2576x1932
2560x1920
2560x1536
2592x1458
1920x1920
2560x1440
2048x1536
2048x1152
1920x1080
1600x1200
1280x720
960x720
800x480
640x480
320x240
Video:
1280x720 (HD)
720x480
640x480 (VGA)
352x288
320x240
176x144
SECONDARY CAMERA
Resolution: 1.9 MP
Video Resolution: VGA, 640x480
Supported Resolutions:
Image:
1600x1200
1280x960
1280x720
960x720
720x480
640x480
320x240
176x144
Video:
640x480 (VGA)
320x240
176x144
The cameraX library versions I am using are
def cameraX = '1.0.0-rc01'
def cameraView = '1.0.0-alpha20'
"androidx.camera:camera-core:${cameraX}"
"androidx.camera:camera-camera2:${cameraX}"
"androidx.camera:camera-view:$cameraView"
"androidx.camera:camera-lifecycle:${cameraX}"
Please help on this, understanding this issue, if something needs to be done at my side.
Thanks
Vikram Mittal