-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebARKitJS.h
More file actions
69 lines (55 loc) · 2.32 KB
/
Copy pathWebARKitJS.h
File metadata and controls
69 lines (55 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <AR/ar.h>
#include <AR2/config.h>
#include <AR2/imageFormat.h>
#include <AR2/util.h>
/*#include <WebARKitTrackers/WebARKitOpticalTracking/WebARKitAkazeTracker.h>
#include <WebARKitTrackers/WebARKitOpticalTracking/WebARKitEnums.h>
#include <WebARKitTrackers/WebARKitOpticalTracking/WebARKitOrbTracker.h>*/
#include <WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.h>
#include <emscripten.h>
#include <emscripten/val.h>
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/opencv.hpp>
#include <stdio.h>
#include <string>
#include <sys/types.h>
#include <unordered_map>
#include <vector>
using namespace emscripten;
class WebARKit {
public:
WebARKit() = default;
WebARKit(int videoWidth, int videoHeight, webarkit::TRACKER_TYPE trackerType) {
this->videoWidth = videoWidth;
this->videoHeight = videoHeight;
this->m_trackerType = trackerType;
m_tracker = std::make_shared<webarkit::WebARKitTracker>(webarkit::WebARKitTracker());
if (this->m_trackerType == webarkit::TRACKER_TYPE::AKAZE_TRACKER || webarkit::TRACKER_TYPE::ORB_TRACKER) {
m_tracker->initialize(trackerType);
} else {
throw std::invalid_argument("Invalid tracker type");
}
}
void initialize_w(int videoWidth, int videoHeight, webarkit::TRACKER_TYPE trackerType);
void loadARParam(std::string paramName, webarkit::TRACKER_TYPE trackerType, size_t xsize, size_t ysize);
void addMarker(emscripten::val data_buffer, std::string filename, int width, int height, int markerID, float scale);
bool GetTrackablePose(int trackableId, float transMat[3][4]);
bool IsTrackableVisible(int trackableId);
emscripten::val getPoseMatrix(int trackableId);
emscripten::val updatePose(int trackableId);
bool updateWithTwoDResults(float trackingTrans[3][4]);
void initTrackerGray(emscripten::val data_buffer, int width, int height);
void processFrame(emscripten::val data_buffer, webarkit::ColorSpace colorSpace);
void processFrame_w(emscripten::val data_buffer);
emscripten::val getHomography();
emscripten::val getCorners();
bool isValid();
private:
ARdouble trans[3][4];
int videoWidth;
int videoHeight;
int m_trackerType;
std::shared_ptr<webarkit::WebARKitTracker> m_tracker;
};