类中未定义的函数

时间:2018-07-24 06:03:22

标签: android c++ android-ndk android-camera2

我是C ++的初学者,无法获取类声明:

class NDKCamera {
 private:
  ACameraManager* cameraMgr_;
  std::map<std::string, CameraId> cameras_;
  std::string activeCameraId_;
  uint32_t cameraFacing_;
  uint32_t cameraOrientation_;

  std::vector<CaptureRequestInfo> requests_;

  ACaptureSessionOutputContainer* outputContainer_;
  ACameraCaptureSession* captureSession_;
  CaptureSessionState captureSessionState_;

  // set up exposure control
  int64_t exposureTime_;
  RangeValue<int64_t> exposureRange_;
  int32_t sensitivity_;
  RangeValue<int32_t> sensitivityRange_;
  volatile bool valid_;

  ACameraManager_AvailabilityCallbacks* GetManagerListener();
  ACameraDevice_stateCallbacks* GetDeviceListener();
  ACameraCaptureSession_stateCallbacks* GetSessionListener();
  ACameraCaptureSession_captureCallbacks* GetCaptureCallback();

 public:
  NDKCamera();
  ~NDKCamera();
  void EnumerateCamera(void);
  bool MatchCaptureSizeRequest(ANativeWindow* display, ImageFormat* view,
                               ImageFormat* capture);
  void CreateSession(ANativeWindow* previewWindow, ANativeWindow* jpgWindow,
                     int32_t imageRotation);
  bool GetSensorOrientation(int32_t* facing, int32_t* angle);
  void OnCameraStatusChanged(const char* id, bool available);
  void OnDeviceState(ACameraDevice* dev);
  void OnDeviceError(ACameraDevice* dev, int err);
  void OnSessionState(ACameraCaptureSession* ses, CaptureSessionState state);
  void OnCaptureSequenceEnd(ACameraCaptureSession* session, int sequenceId,
                            int64_t frameNumber);
  void OnCaptureFailed(ACameraCaptureSession* session, ACaptureRequest* request,
                       ACameraCaptureFailure* failure);
  void StartPreview(bool start);
  bool TakePhoto(void);
  bool GetExposureRange(int64_t* min, int64_t* max, int64_t* curVal);
  bool GetSensitivityRange(int64_t* min, int64_t* max, int64_t* curVal);

  void UpdateCameraRequestParameter(int32_t code, int64_t val);
};

此类包含下一个函数的声明:

ACameraManager_AvailabilityCallbacks* GetManagerListener();
ACameraDevice_stateCallbacks* GetDeviceListener();
ACameraCaptureSession_stateCallbacks* GetSessionListener();
ACameraCaptureSession_captureCallbacks* GetCaptureCallback();

但是这些函数没有定义。
通过以下示例链接到存储库:https://github.com/googlesamples/android-ndk/blob/master/camera/

基于该代码的我自己的项目在构建时失败,并显示以下消息:

/home/ghostman/Projects/Android/daVinci/app/src/main/cpp/src/camera_manager.cpp:37: error: undefined reference to 'DaVinci::CameraManager::GetDeviceListener()'
/home/ghostman/Projects/Android/daVinci/app/src/main/cpp/src/camera_manager.cpp:39: error: undefined reference to 'DaVinci::CameraManager::GetManagerListener()'

但是我什至无法获得修复错误的代码。有人可以解释这些功能的定义在哪里吗?

1 个答案:

答案 0 :(得分:1)

您的app/src/main/cpp/src/camera_manager.cpp显然有以下说法

namespace DaVinci { …
}

但是您应该在这个命名空间中不要包含includes

#include <camera/NdkCameraManager.h>
#include <camera/NdkCameraError.h>
#include <camera/NdkCameraDevice.h>
#include <camera/NdkCameraMetadataTags.h>