MCPcopy Create free account
hub / github.com/android/ndk-samples / GetSensorOrientation

Method GetSensorOrientation

camera/basic/src/main/cpp/camera_manager.cpp:354–377  ·  view source on GitHub ↗

* GetSensorOrientation() * Retrieve current sensor orientation regarding to the phone device * orientation * SensorOrientation is NOT settable. */

Source from the content-addressed store, hash-verified

352 * SensorOrientation is NOT settable.
353 */
354bool NDKCamera::GetSensorOrientation(int32_t* facing, int32_t* angle) {
355 if (!cameraMgr_) {
356 return false;
357 }
358
359 ACameraMetadata* metadataObj;
360 ACameraMetadata_const_entry face, orientation;
361 CALL_MGR(getCameraCharacteristics(cameraMgr_, activeCameraId_.c_str(),
362 &metadataObj));
363 CALL_METADATA(getConstEntry(metadataObj, ACAMERA_LENS_FACING, &face));
364 cameraFacing_ = static_cast<int32_t>(face.data.u8[0]);
365
366 CALL_METADATA(
367 getConstEntry(metadataObj, ACAMERA_SENSOR_ORIENTATION, &orientation));
368
369 LOGI("====Current SENSOR_ORIENTATION: %8d", orientation.data.i32[0]);
370
371 ACameraMetadata_free(metadataObj);
372 cameraOrientation_ = orientation.data.i32[0];
373
374 if (facing) *facing = cameraFacing_;
375 if (angle) *angle = cameraOrientation_;
376 return true;
377}
378
379/**
380 * StartPreview()

Callers 1

CreateCameraMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected