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  virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height);
71 
72  virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
73  void setupGL();
74  virtual void close(); // close Tango connection
75  virtual std::string getSerial() const;
76  GLuint getTextureId() const {return textureId_;}
77 
78  void imageCallback(AImageReader *reader);
79 
80 protected:
81  virtual SensorData captureImage(CameraInfo * info = 0); // should be called in opengl thread
82  virtual void capturePoseOnly();
83 
84 private:
85  rtabmap::Transform getPoseAtTimestamp(double timestamp);
86 
87 private:
88  void * env_;
89  void * context_;
90  void * activity_;
91  ArSession* arSession_ = nullptr;
92  ArConfig* arConfig_ = nullptr;
93  ArFrame* arFrame_ = nullptr;
94  ArCameraIntrinsics *arCameraIntrinsics_ = nullptr;
95  ArPose * arPose_ = nullptr;
98 
100 };
101 
102 } /* namespace rtabmap */
103 #endif /* CAMERAARCORE_H_ */
void imageCallback(AImageReader *reader)
ArCameraIntrinsics * arCameraIntrinsics_
Definition: CameraARCore.h:94
virtual void close()
bool uvsInitialized() const
Definition: CameraARCore.h:66
ArSession * arSession_
Definition: CameraARCore.h:91
virtual std::string getSerial() const
virtual SensorData captureImage(CameraInfo *info=0)
virtual void capturePoseOnly()
unsigned int GLuint
Definition: dummy.cpp:78
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)
const float * uvsTransformed() const
Definition: CameraARCore.h:67
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
model
Definition: trace.py:4
GLuint getTextureId() const
Definition: CameraARCore.h:76
ScreenRotation
Definition: util.h:194
CameraARCore(void *env, void *context, void *activity, bool depthFromMotion=false, bool smoothing=false)
glm::mat4 projectionMatrix_
Definition: CameraMobile.h:139
void getVPMatrices(glm::mat4 &view, glm::mat4 &projection) const
Definition: CameraARCore.h:68
virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:27