CameraARCore.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef CAMERAARCORE_H_
29 #define CAMERAARCORE_H_
30 
31 #include "CameraMobile.h"
32 #include <rtabmap/core/Camera.h>
34 #include <rtabmap/utilite/UMutex.h>
38 #include <rtabmap/utilite/UEvent.h>
39 #include <rtabmap/utilite/UTimer.h>
40 #include <boost/thread/mutex.hpp>
41 #include <background_renderer.h>
42 
43 #include <arcore_c_api.h>
44 #include <camera/NdkCameraDevice.h>
45 #include <camera/NdkCameraManager.h>
46 #include <media/NdkImageReader.h>
47 #include <android/native_window.h>
48 
49 namespace rtabmap {
50 
51 class CameraARCore : public CameraMobile {
52 public:
54  const float * pointCloudData,
55  int points,
56  const Transform & pose,
57  const CameraModel & model,
58  const cv::Mat & rgb,
59  std::vector<cv::KeyPoint> * kpts = 0,
60  std::vector<cv::Point3f> * kpts3D = 0);
61 
62 public:
63  CameraARCore(void* env, void* context, void* activity, bool depthFromMotion = false, bool smoothing = false);
64  virtual ~CameraARCore();
65 
66  bool uvsInitialized() const {return uvs_initialized_;}
67  const float* uvsTransformed() const {return transformed_uvs_;}
68  void getVPMatrices(glm::mat4 & view, glm::mat4 & projection) const {view=viewMatrix_; projection=projectionMatrix_;}
69 
70  void updateOcclusionImage(bool enabled) {updateOcclusionImage_ = enabled;}
71  const cv::Mat & getOcclusionImage(CameraModel * model=0) const {if(model)*model=occlusionModel_; return occlusionImage_; }
72 
73  virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height);
74 
75  virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
76  void setupGL();
77  virtual void close(); // close Tango connection
78  virtual std::string getSerial() const;
79  GLuint getTextureId() const {return textureId_;}
80 
81  void imageCallback(AImageReader *reader);
82 
83 protected:
84  virtual SensorData captureImage(CameraInfo * info = 0); // should be called in opengl thread
85  virtual void capturePoseOnly();
86 
87 private:
88  rtabmap::Transform getPoseAtTimestamp(double timestamp);
89 
90 private:
91  void * env_;
92  void * context_;
93  void * activity_;
94  ArSession* arSession_ = nullptr;
95  ArConfig* arConfig_ = nullptr;
96  ArFrame* arFrame_ = nullptr;
97  ArCameraIntrinsics *arCameraIntrinsics_ = nullptr;
98  ArPose * arPose_ = nullptr;
102 
104  bool uvs_initialized_ = false;
107 
112 };
113 
114 } /* namespace rtabmap */
115 #endif /* CAMERAARCORE_H_ */
void imageCallback(AImageReader *reader)
ArCameraIntrinsics * arCameraIntrinsics_
Definition: CameraARCore.h:97
virtual void close()
void getVPMatrices(glm::mat4 &view, glm::mat4 &projection) const
Definition: CameraARCore.h:68
void updateOcclusionImage(bool enabled)
Definition: CameraARCore.h:70
const cv::Mat & getOcclusionImage(CameraModel *model=0) const
Definition: CameraARCore.h:71
ArSession * arSession_
Definition: CameraARCore.h:94
virtual SensorData captureImage(CameraInfo *info=0)
static constexpr int kNumVertices
virtual void capturePoseOnly()
unsigned int GLuint
Definition: dummy.cpp:78
const float * uvsTransformed() const
Definition: CameraARCore.h:67
virtual std::string getSerial() const
float transformed_uvs_[BackgroundRenderer::kNumVertices *2]
Definition: CameraARCore.h:103
CameraModel occlusionModel_
Definition: CameraARCore.h:110
Definition: UMutex.h:54
rtabmap::Transform getPoseAtTimestamp(double timestamp)
static LaserScan scanFromPointCloudData(const float *pointCloudData, int points, const Transform &pose, const CameraModel &model, const cv::Mat &rgb, std::vector< cv::KeyPoint > *kpts=0, std::vector< cv::Point3f > *kpts3D=0)
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
GLuint getTextureId() const
Definition: CameraARCore.h:79
glm::mat4 projectionMatrix_
Definition: CameraARCore.h:106
bool uvsInitialized() const
Definition: CameraARCore.h:66
ScreenRotation
Definition: util.h:192
CameraARCore(void *env, void *context, void *activity, bool depthFromMotion=false, bool smoothing=false)
virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:58