|
|
@ -23,21 +23,24 @@
|
|
|
|
#include "Camera2Helper.h"
|
|
|
|
#include "Camera2Helper.h"
|
|
|
|
#include <AndroidHelper.h>
|
|
|
|
#include <AndroidHelper.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <LogThread.h>
|
|
|
|
|
|
|
|
|
|
|
|
static void onAvailabilityCallback(void* context, const char* cameraId)
|
|
|
|
static void onAvailabilityCallback(void* context, const char* cameraId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
((NdkCamera*)context)->onAvailabilityCallback(cameraId);
|
|
|
|
((NdkCamera*)context)->onAvailabilityCallback(cameraId);
|
|
|
|
ALOGI("CameraStatus::onAvailability CameraId: %s", cameraId);
|
|
|
|
// ALOGI("CameraStatus::onAvailability CameraId: %s", cameraId);
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "CameraStatus::onAvailability CameraId: %s", cameraId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void onUnavailabilityCallback(void* context, const char* cameraId)
|
|
|
|
static void onUnavailabilityCallback(void* context, const char* cameraId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
((NdkCamera*)context)->onUnavailabilityCallback(cameraId);
|
|
|
|
((NdkCamera*)context)->onUnavailabilityCallback(cameraId);
|
|
|
|
ALOGI("CameraStatus::onUnavailability CameraId: %s", cameraId);
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "CameraStatus::onUnavailability CameraId: %s", cameraId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void onDisconnected(void* context, ACameraDevice* device)
|
|
|
|
static void onDisconnected(void* context, ACameraDevice* device)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ALOGI("CameraStatus::onDisconnected CameraId: %s", ACameraDevice_getId(device));
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "CameraStatus::onDisconnected CameraId: %s", ACameraDevice_getId(device));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void onError(void* context, ACameraDevice* device, int error)
|
|
|
|
static void onError(void* context, ACameraDevice* device, int error)
|
|
|
@ -47,7 +50,7 @@ static void onError(void* context, ACameraDevice* device, int error)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ALOGE("CameraStatus::onError CameraId: %s err=%d", ACameraDevice_getId(device), error);
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "CameraStatus::onError CameraId: %s err=%d", ACameraDevice_getId(device), error);
|
|
|
|
std::string msg = "NdkCamera error code=" + std::to_string(error);
|
|
|
|
std::string msg = "NdkCamera error code=" + std::to_string(error);
|
|
|
|
((NdkCamera*)context)->on_error(msg);
|
|
|
|
((NdkCamera*)context)->on_error(msg);
|
|
|
|
// __android_log_print(ANDROID_LOG_WARN, "NdkCamera", "onError %p %d", device, error);
|
|
|
|
// __android_log_print(ANDROID_LOG_WARN, "NdkCamera", "onError %p %d", device, error);
|
|
|
@ -75,7 +78,7 @@ static void onSessionClosed(void* context, ACameraCaptureSession *session)
|
|
|
|
|
|
|
|
|
|
|
|
void onCaptureFailed(void* context, ACameraCaptureSession* session, ACaptureRequest* request, ACameraCaptureFailure* failure)
|
|
|
|
void onCaptureFailed(void* context, ACameraCaptureSession* session, ACaptureRequest* request, ACameraCaptureFailure* failure)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ALOGW("onCaptureFailed session=%p request=%p reason=%d", session, request, failure->reason);
|
|
|
|
XYLOG(XYLOG_SEVERITY_WARNING, "onCaptureFailed session=%p request=%p reason=%d", session, request, failure->reason);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void onCaptureSequenceCompleted(void* context, ACameraCaptureSession* session, int sequenceId, int64_t frameNumber)
|
|
|
|
void onCaptureSequenceCompleted(void* context, ACameraCaptureSession* session, int sequenceId, int64_t frameNumber)
|
|
|
@ -159,7 +162,6 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
DisplayDimension disp(mWidth, mHeight);
|
|
|
|
DisplayDimension disp(mWidth, mHeight);
|
|
|
|
DisplayDimension foundRes = disp;
|
|
|
|
DisplayDimension foundRes = disp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALOGD("Start ACameraManager_getCameraIdList");
|
|
|
|
ALOGD("Start ACameraManager_getCameraIdList");
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ACameraIdList *camera_id_list = 0;
|
|
|
|
ACameraIdList *camera_id_list = 0;
|
|
|
@ -382,6 +384,7 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
listener.context = this;
|
|
|
|
listener.context = this;
|
|
|
|
listener.onImageAvailable = ::onImageAvailable;
|
|
|
|
listener.onImageAvailable = ::onImageAvailable;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AImageReader_setO
|
|
|
|
AImageReader_setImageListener(image_reader, &listener);
|
|
|
|
AImageReader_setImageListener(image_reader, &listener);
|
|
|
|
|
|
|
|
|
|
|
|
AImageReader_getWindow(image_reader, &image_reader_surface);
|
|
|
|
AImageReader_getWindow(image_reader, &image_reader_surface);
|
|
|
@ -721,17 +724,29 @@ void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_hei
|
|
|
|
cv::Mat nv21_rotated;
|
|
|
|
cv::Mat nv21_rotated;
|
|
|
|
const unsigned char* yuv420data = nv21;
|
|
|
|
const unsigned char* yuv420data = nv21;
|
|
|
|
// TODO !!!???
|
|
|
|
// TODO !!!???
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if (camera_->GetSensorOrientation(&facing, &angle)) {
|
|
|
|
|
|
|
|
if (facing == ACAMERA_LENS_FACING_FRONT) {
|
|
|
|
|
|
|
|
imageRotation = (angle + rotation_) % 360;
|
|
|
|
|
|
|
|
imageRotation = (360 - imageRotation) % 360;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
imageRotation = (angle - rotation_ + 360) % 360;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// int co = camera_orientation > 0 ? camera_orientation + 90 : camera_orientation;
|
|
|
|
// int co = camera_orientation > 0 ? camera_orientation + 90 : camera_orientation;
|
|
|
|
if (m_params.orientation != 0)
|
|
|
|
if (m_params.orientation != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int co = 0;
|
|
|
|
int co = 0;
|
|
|
|
if (camera_facing == ACAMERA_LENS_FACING_FRONT)
|
|
|
|
if (camera_facing == ACAMERA_LENS_FACING_FRONT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
co = (camera_orientation - (m_params.orientation - 1) * 90 + 360) % 360;
|
|
|
|
co = (camera_orientation + (m_params.orientation - 1) * 90) % 360;
|
|
|
|
|
|
|
|
co = (360 - co) % 360;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
co = (camera_orientation + (m_params.orientation - 1) * 90) % 360;
|
|
|
|
co = (camera_orientation - (m_params.orientation - 1) * 90 + 360) % 360;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// int co = 0;
|
|
|
|
// int co = 0;
|
|
|
|
if (co == 0)
|
|
|
|
if (co == 0)
|
|
|
|