ARX  1.0
The next-generation open source augmented reality toolkit.
Loading...
Searching...
No Matches
ARVideoSource.h
Go to the documentation of this file.
1/*
2 * ARVideoSource.h
3 * artoolkitX
4 *
5 * This file is part of artoolkitX.
6 *
7 * artoolkitX is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * artoolkitX is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with artoolkitX. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * As a special exception, the copyright holders of this library give you
21 * permission to link this library with independent modules to produce an
22 * executable, regardless of the license terms of these independent modules, and to
23 * copy and distribute the resulting executable under terms of your choice,
24 * provided that you also meet, for each linked independent module, the terms and
25 * conditions of the license of that module. An independent module is a module
26 * which is neither derived from nor based on this library. If you modify this
27 * library, you may extend this exception to your version of the library, but you
28 * are not obligated to do so. If you do not wish to do so, delete this exception
29 * statement from your version.
30 *
31 * Copyright 2018 Realmax, Inc.
32 * Copyright 2015-2016 Daqri, LLC.
33 * Copyright 2010-2015 ARToolworks, Inc.
34 *
35 */
36
37#ifndef VIDEOSOURCE_H
38#define VIDEOSOURCE_H
39
40#include <ARX/Platform.h>
41
42#include <ARX/AR/ar.h>
43#include <ARX/ARVideo/video.h>
44
45#include <mutex>
46#include <pthread.h>
47
53class ARX_EXTERN ARVideoSource {
54
55private:
56
57 typedef enum {
58 DEVICE_CLOSED,
59 DEVICE_OPEN,
60 DEVICE_GETTING_READY,
61 DEVICE_RUNNING
62 } DeviceState;
63
64 DeviceState deviceState;
65
66 AR2VideoParamT *m_vid;
67 bool m_noCpara;
68 char* cameraParam;
69 char* cameraParamBuffer;
70 size_t cameraParamBufferLen;
71 ARParamLT *cparamLT;
72
73 char* videoConfiguration;
74
75 int videoWidth;
76 int videoHeight;
77
78 AR_PIXEL_FORMAT pixelFormat;
79
80 int m_captureFrameWaitCount;
81
82 AR2VideoBufferT *m_frameBuffer;
83
84 AR2VideoTimestampT m_getFrameTextureTime;
85
86 int m_error;
87 void setError(int error);
88
89 pthread_rwlock_t m_frameBufferLock;
90
91 static void openCallback(void *userData);
92 bool open2();
93 static void open2CparamCallback(const ARParam *cparam_p, void *userdata);
94 bool open3(const ARParam *cparam_p);
95
96public:
97
99
101
102 int getError();
103
108 bool isOpen() const;
109
114 bool isRunning() const;
115
124 void configure(const char* vconf, bool noCpara, const char* cparaName, const char* cparaBuff, size_t cparaBuffLen);
125
130 ARParamLT* getCameraParameters() const;
131
136 int getVideoWidth() const;
137
142 int getVideoHeight() const;
143
148 AR_PIXEL_FORMAT getPixelFormat() const;
149
154 bool open();
155
160 bool close();
161
166 bool captureFrame();
167
183 AR2VideoBufferT* checkoutFrameIfNewerThan(const AR2VideoTimestampT time);
184
191 void checkinFrame(void);
192
200 AR2VideoParamT *getAR2VideoParam(void);
201
207 bool getFrameTextureRGBA32(uint32_t *buffer);
208
209#if ARX_TARGET_PLATFORM_ANDROID
210 jint androidVideoPushInit(JNIEnv *env, jobject obj, jint width, jint height, const char *pixelFormat, jint camera_index, jint camera_face);
211 jint androidVideoPush1(JNIEnv *env, jobject obj, jbyteArray buf, jint bufSize);
212 jint androidVideoPush2(JNIEnv *env, jobject obj,
213 jobject buf0, jint buf0PixelStride, jint buf0RowStride,
214 jobject buf1, jint buf1PixelStride, jint buf1RowStride,
215 jobject buf2, jint buf2PixelStride, jint buf2RowStride,
216 jobject buf3, jint buf3PixelStride, jint buf3RowStride);
217 jint androidVideoPushFinal(JNIEnv *env, jobject obj);
218#endif
219
220};
221
222#endif // !VIDEOSOURCE_H
artoolkitX core routines.
A video source provides video frames to the artoolkitX tracking module.
Definition: ARVideoSource.h:53
A structure which carries information about a video frame retrieved by the video library.
Definition: ar.h:148
Definition: video.h:315
A structure to hold a timestamp in seconds and microseconds, with arbitrary epoch.
Definition: ar.h:139
Structure holding camera parameters, including image size, projection matrix and lens distortion para...
Definition: param.h:99
Structure holding camera parameters, in lookup table form.
Definition: param.h:151