|
|
@ -38,8 +38,7 @@ static const uint64_t kMaxExposureTime = static_cast<uint64_t>(250000000);
|
|
|
|
#define WAIT_AWB_LOCKED 2
|
|
|
|
#define WAIT_AWB_LOCKED 2
|
|
|
|
#define WAIT_AF_LOCKED 4
|
|
|
|
#define WAIT_AF_LOCKED 4
|
|
|
|
|
|
|
|
|
|
|
|
// #define EXPECTED_CAPTURE_IDX 0
|
|
|
|
#define PREVIEW_REQUEST_IDX 0
|
|
|
|
#define EXPECTED_CAPTURE_IDX 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CameraManager
|
|
|
|
class CameraManager
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -105,8 +104,8 @@ public:
|
|
|
|
int32_t compensation;
|
|
|
|
int32_t compensation;
|
|
|
|
uint8_t sceneMode;
|
|
|
|
uint8_t sceneMode;
|
|
|
|
uint8_t awbMode;
|
|
|
|
uint8_t awbMode;
|
|
|
|
|
|
|
|
uint16_t avgY;
|
|
|
|
float zoomRatio;
|
|
|
|
float zoomRatio;
|
|
|
|
uint8_t avgY;
|
|
|
|
|
|
|
|
uint64_t duration;
|
|
|
|
uint64_t duration;
|
|
|
|
int64_t frameDuration;
|
|
|
|
int64_t frameDuration;
|
|
|
|
|
|
|
|
|
|
|
@ -115,7 +114,28 @@ public:
|
|
|
|
uint8_t afLockSetted : 1;
|
|
|
|
uint8_t afLockSetted : 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
NdkCamera(int32_t width, int32_t height, const CAMERA_PARAMS& params);
|
|
|
|
struct CaptureRequest
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* For image capture */
|
|
|
|
|
|
|
|
NdkCamera* pThis;
|
|
|
|
|
|
|
|
AImageReader* imageReader;
|
|
|
|
|
|
|
|
ANativeWindow* imageWindow;
|
|
|
|
|
|
|
|
ACameraOutputTarget* imageTarget;
|
|
|
|
|
|
|
|
ACaptureSessionOutput* sessionOutput;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ACaptureRequest* request;
|
|
|
|
|
|
|
|
ACameraDevice_request_template templateId;
|
|
|
|
|
|
|
|
int sessionSequenceId;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct CaptureResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ACameraMetadata* result;
|
|
|
|
|
|
|
|
AImage* image;
|
|
|
|
|
|
|
|
int sequenceId;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NdkCamera(int32_t width, int32_t height, const CAMERA_PARAMS& params, int burstCaptures = 1);
|
|
|
|
virtual ~NdkCamera();
|
|
|
|
virtual ~NdkCamera();
|
|
|
|
|
|
|
|
|
|
|
|
// facing 0=front 1=back
|
|
|
|
// facing 0=front 1=back
|
|
|
@ -123,12 +143,19 @@ public:
|
|
|
|
void close();
|
|
|
|
void close();
|
|
|
|
|
|
|
|
|
|
|
|
int selfTest(const std::string& cameraId, int32_t& maxResolutionX, int32_t& maxResolutionY);
|
|
|
|
int selfTest(const std::string& cameraId, int32_t& maxResolutionX, int32_t& maxResolutionY);
|
|
|
|
|
|
|
|
void writeJpegFile(AImage *image, const char* path);
|
|
|
|
|
|
|
|
void writeRawFile(AImage *image, const char* path);
|
|
|
|
|
|
|
|
|
|
|
|
void onAvailabilityCallback(const char* cameraId);
|
|
|
|
void onAvailabilityCallback(const char* cameraId);
|
|
|
|
void onUnavailabilityCallback(const char* cameraId);
|
|
|
|
void onUnavailabilityCallback(const char* cameraId);
|
|
|
|
virtual void onImageAvailable(AImageReader* reader);
|
|
|
|
virtual void onImageAvailable(AImageReader* reader);
|
|
|
|
virtual int32_t getOutputFormat() const;
|
|
|
|
virtual int32_t getOutputFormat() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CreateSession(ANativeWindow* previewWindow, ANativeWindow* jpgWindow, bool manaulPreview, int32_t imageRotation, int32_t width, int32_t height);
|
|
|
|
|
|
|
|
void CreateSession(ANativeWindow* previewWindow);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DestroySession();
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool on_image(cv::Mat& rgb);
|
|
|
|
virtual bool on_image(cv::Mat& rgb);
|
|
|
|
virtual void on_error(const std::string& msg);
|
|
|
|
virtual void on_error(const std::string& msg);
|
|
|
|
virtual void on_image(const unsigned char* nv21, int nv21_width, int nv21_height);
|
|
|
|
virtual void on_image(const unsigned char* nv21, int nv21_width, int nv21_height);
|
|
|
@ -151,8 +178,12 @@ protected:
|
|
|
|
std::mutex m_locker;
|
|
|
|
std::mutex m_locker;
|
|
|
|
std::set<std::string> m_availableCameras;
|
|
|
|
std::set<std::string> m_availableCameras;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::atomic<uint32_t> mFrameNumber;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
CAMERA_PARAMS m_params;
|
|
|
|
CAMERA_PARAMS m_params;
|
|
|
|
|
|
|
|
int mBurstCaptures;
|
|
|
|
int camera_facing;
|
|
|
|
int camera_facing;
|
|
|
|
int camera_orientation;
|
|
|
|
int camera_orientation;
|
|
|
|
bool m_firstFrame;
|
|
|
|
bool m_firstFrame;
|
|
|
@ -181,7 +212,7 @@ protected:
|
|
|
|
int32_t activeArraySize[2];
|
|
|
|
int32_t activeArraySize[2];
|
|
|
|
int32_t maxRegions[3];
|
|
|
|
int32_t maxRegions[3];
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int m_imagesCaptured;
|
|
|
|
bool mCaptureTriggered;
|
|
|
|
|
|
|
|
|
|
|
|
CAPTURE_RESULT mResult;
|
|
|
|
CAPTURE_RESULT mResult;
|
|
|
|
CAPTURE_RESULT mFinalResult;
|
|
|
|
CAPTURE_RESULT mFinalResult;
|
|
|
@ -193,15 +224,29 @@ protected:
|
|
|
|
|
|
|
|
|
|
|
|
CameraManager camera_manager;
|
|
|
|
CameraManager camera_manager;
|
|
|
|
ACameraDevice* camera_device;
|
|
|
|
ACameraDevice* camera_device;
|
|
|
|
AImageReader* image_reader;
|
|
|
|
|
|
|
|
ANativeWindow* image_reader_surface;
|
|
|
|
|
|
|
|
ACameraOutputTarget* image_reader_target;
|
|
|
|
|
|
|
|
ACaptureRequest* capture_request;
|
|
|
|
|
|
|
|
ACaptureSessionOutputContainer* capture_session_output_container;
|
|
|
|
ACaptureSessionOutputContainer* capture_session_output_container;
|
|
|
|
ACaptureSessionOutput* capture_session_output;
|
|
|
|
|
|
|
|
|
|
|
|
AImageReader* mPreviewImageReader;
|
|
|
|
|
|
|
|
ANativeWindow* mPreviewImageWindow;
|
|
|
|
|
|
|
|
ACameraOutputTarget* mPreviewOutputTarget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AImageReader* mImageReader;
|
|
|
|
|
|
|
|
ANativeWindow* mImageWindow;
|
|
|
|
|
|
|
|
ACameraOutputTarget* mOutputTarget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<CaptureRequest*> mCaptureRequests;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<CaptureResult> mCaptureResults;
|
|
|
|
|
|
|
|
|
|
|
|
ACameraCaptureSession* capture_session;
|
|
|
|
ACameraCaptureSession* capture_session;
|
|
|
|
|
|
|
|
|
|
|
|
int captureSequenceId;
|
|
|
|
// AImageReader* image_reader;
|
|
|
|
|
|
|
|
// ANativeWindow* image_reader_surface;
|
|
|
|
|
|
|
|
// ACameraOutputTarget* image_reader_target;
|
|
|
|
|
|
|
|
// ACaptureRequest* capture_request;
|
|
|
|
|
|
|
|
// ACaptureSessionOutput* capture_session_output;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NDKCAMERA_H
|
|
|
|
#endif // NDKCAMERA_H
|
|
|
|