-
Notifications
You must be signed in to change notification settings - Fork 2
[WIP] Feature multi marker #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kalwalt
wants to merge
12
commits into
dev
Choose a base branch
from
feature-multi-marker
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
769be9c
first raw code for Multi Marker
kalwalt 6e5a419
testing Promise.all
kalwalt 62954f6
new tracker _TMM_ES6 loader and WASM file
kalwalt 95e5ed3
testing multi marker - only loadCamera
kalwalt 99306af
adding devcontainer file
kalwalt bdde96a
multi marker load without errors now
kalwalt 5d250ef
trackerMM_ES6_debug lib
kalwalt 1451dd2
test for loading config file
kalwalt 3655293
parseMultiFile and ajaxDependencies
kalwalt 07a22ef
this load as in jsartoolkit5 but also fails
kalwalt 7765c73
Merge branch 'main' into feature-multi-marker
kalwalt c8eebdb
rebuilding libs after merging
kalwalt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <emscripten/bind.h> | ||
|
||
using namespace emscripten; | ||
|
||
EMSCRIPTEN_BINDINGS(TrackerMM) { | ||
register_vector<int>("vector_int"); | ||
|
||
enum_<PIXEL_FORMAT>("PIXEL_FORMAT") | ||
.value("PIXEL_FORMAT_ABGR", PIXEL_FORMAT_ABGR) | ||
.value("PIXEL_FORMAT_BGRA", PIXEL_FORMAT_BGRA) | ||
.value("PIXEL_FORMAT_BGR", PIXEL_FORMAT_BGR) | ||
.value("PIXEL_FORMAT_RGBA", PIXEL_FORMAT_RGBA) | ||
.value("PIXEL_FORMAT_RGB", PIXEL_FORMAT_RGB) | ||
.value("PIXEL_FORMAT_RGB565", PIXEL_FORMAT_RGB565) | ||
.value("PIXEL_FORMAT_LUM", PIXEL_FORMAT_LUM); | ||
|
||
class_<TrackerMM>("TrackerMultiMarker") | ||
.constructor<bool, int, int, int>() | ||
.function("setup", &TrackerMM::setup) | ||
.function("update", &TrackerMM::update) | ||
.function("getMarkerId", &TrackerMM::getMarkerId) | ||
.function("getMarkerPos", &TrackerMM::getMarkerPos) | ||
.function("getMarkerVertexes", &TrackerMM::getMarkerVertexes) | ||
.function("getModelViewMatrix", &TrackerMM::getMVMatrix) | ||
.function("getPixelFormat", &TrackerMM::getPixelFormat) | ||
.function("getProjectionMatrix", &TrackerMM::getProjectionMatrix) | ||
.function("printCameraSettings", &TrackerMM::printCameraSettings) | ||
.function("setBorderWidth", &TrackerMM::setBorderWidth) | ||
.function("setMarkerMode", &TrackerMM::setMarkerMode) | ||
.function("setPixelFormat", &TrackerMM::setPixelFormat) | ||
.function("setThreshold", &TrackerMM::setThreshold) | ||
.function("setUndistortionMode", &TrackerMM::setUndistortionMode); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#include "trackerMM.h" | ||
|
||
void TrackerMM::setup(string camParamFile, string multiFile, int maxImagePatterns, int pattWidth, | ||
int pattHeight, int pattSamples, int maxLoadPatterns) { | ||
// ---------------------------------- AR TK+ STUFF - ripped from the single | ||
// marker demo app | ||
|
||
// create a tracker that does: | ||
// - "pattWidth" x "pattHeight" sized marker images (6x6 required for binary | ||
// markers) | ||
// - samples at a maximum of 6x6 | ||
// - works with luminance (gray) images | ||
// - can load a maximum of "maxLoadPatterns" non-binary pattern | ||
// - can detect a maximum of "maxImagePatterns" patterns in one image | ||
tracker = make_unique<ARToolKitPlus::TrackerMultiMarker>( | ||
this->mWidth, this->mHeight, maxImagePatterns, pattWidth, pattHeight, | ||
pattSamples, maxLoadPatterns); | ||
|
||
// set a logger so we can output error messages | ||
// tracker->setLogger(&logger); | ||
// - works with luminance (gray) images | ||
tracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_LUM); | ||
|
||
tracker->setImageProcessingMode(ARToolKitPlus::IMAGE_FULL_RES); | ||
|
||
// Initialize a Single Marker Tracker with | ||
// Camera and near and far clipping values for the OpenGL projection matrix | ||
/*if (!tracker->init(camParamFile.c_str(), multiFile.c_str(), 1.0f, 1000.0f)) { | ||
|
||
printf("ERROR: init() failed\n"); | ||
tracker = nullptr; | ||
|
||
return; | ||
}*/ | ||
if (!tracker->loadCameraFile(camParamFile.c_str(), 1.0f, 1000.0f)) { | ||
printf("ERROR: loadCameraFile() failed\n"); | ||
tracker = nullptr; | ||
|
||
return; | ||
} | ||
tracker->getCamera()->printSettings(); | ||
// define size of the marker | ||
//tracker->setPatternWidth(this->mPatternWidth); | ||
// multimarkers since it doesnt seem to have this option. | ||
|
||
// the marker in the BCH test image has a thin border... | ||
tracker->setBorderWidth(this->useBCH ? 0.125f : 0.250f); | ||
// tracker->setBorderWidth(0.250f); | ||
|
||
// set a threshold. alternatively we could also activate automatic | ||
// thresholding | ||
tracker->setThreshold(85); | ||
|
||
// let's use lookup-table undistortion for high-speed | ||
// note: LUT only works with images up to 1024x1024 | ||
tracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT); | ||
// tracker->setUndistortionMode(ARToolKitPlus::UNDIST_STD); | ||
|
||
// RPP is more robust than ARToolKit's standard pose estimator | ||
tracker->setPoseEstimator(ARToolKitPlus::POSE_ESTIMATOR_RPP); | ||
|
||
// switch to simple ID based markers | ||
// use the tool in tools/IdPatGen to generate markers | ||
tracker->setMarkerMode(useBCH ? ARToolKitPlus::MARKER_ID_BCH | ||
: ARToolKitPlus::MARKER_ID_SIMPLE); | ||
// tracker->activateVignettingCompensation(true); | ||
|
||
// tracker->setUseDetectLite(false); | ||
} | ||
|
||
int TrackerMM::getMarkerId() { return marker_info->id; }; | ||
|
||
emscripten::val TrackerMM::getMarkerPos() { | ||
emscripten::val obj = emscripten::val::object(); | ||
obj.set("x", marker_info->pos[0]); | ||
obj.set("y", marker_info->pos[1]); | ||
return obj; | ||
} | ||
|
||
emscripten::val TrackerMM::getMarkerVertexes() { | ||
emscripten::val vertexes = emscripten::val::array(); | ||
for (auto x = 0; x < 4; x++) { | ||
for (auto y = 0; y < 2; y++) { | ||
vertexes.call<void>("push", marker_info->vertex[x][y]); | ||
} | ||
} | ||
return vertexes; | ||
} | ||
|
||
int TrackerMM::update(emscripten::val data_buffer) { | ||
vector<uint8_t> u8 = | ||
emscripten::convertJSArrayToNumberVector<uint8_t>(data_buffer); | ||
return tracker->calc(u8.data()); | ||
} | ||
|
||
emscripten::val TrackerMM::getMVMatrix() { | ||
emscripten::val arr = emscripten::val::array(); | ||
const ARFloat *ptr = tracker->getModelViewMatrix(); | ||
for (auto i = 0; i < 16; i++) { | ||
arr.call<void>("push", ptr[i]); | ||
} | ||
return arr; | ||
} | ||
|
||
bool TrackerMM::setPixelFormat(PIXEL_FORMAT nFormat) { | ||
return tracker->setPixelFormat(nFormat); | ||
} | ||
|
||
PIXEL_FORMAT TrackerMM::getPixelFormat() { return tracker->getPixelFormat(); } | ||
|
||
emscripten::val TrackerMM::getProjectionMatrix() { | ||
emscripten::val arr = emscripten::val::array(); | ||
const ARFloat *ptr = tracker->getProjectionMatrix(); | ||
for (auto i = 0; i < 16; i++) { | ||
arr.call<void>("push", ptr[i]); | ||
} | ||
return arr; | ||
} | ||
|
||
void TrackerMM::printCameraSettings() { | ||
tracker->getCamera()->printSettings(); | ||
}; | ||
|
||
void TrackerMM::setBorderWidth(ARFloat nFraction) { | ||
tracker->setBorderWidth(nFraction); | ||
} | ||
|
||
void TrackerMM::setMarkerMode(MARKER_MODE nMarkerMode) { | ||
tracker->setMarkerMode(nMarkerMode); | ||
}; | ||
|
||
void TrackerMM::setThreshold(int nValue) { tracker->setBorderWidth(nValue); } | ||
|
||
void TrackerMM::setUndistortionMode(UNDIST_MODE nMode) { | ||
tracker->setUndistortionMode(nMode); | ||
}; | ||
|
||
#include "TrackerMM-bindings.cpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <ARToolKitPlus/TrackerMultiMarker.h> | ||
#include <ARToolKitPlus/ar.h> | ||
#include <algorithm> | ||
#include <emscripten/val.h> | ||
|
||
using namespace ARToolKitPlus; | ||
using namespace std; | ||
|
||
class TrackerMM { | ||
public: | ||
TrackerMM(bool useBCH, int width, int height, int patternWidth) { | ||
this->useBCH = useBCH; | ||
this->mWidth = width; | ||
this->mHeight = height; | ||
this->mPatternWidth = patternWidth; | ||
}; | ||
//~TrackerMM(); | ||
|
||
void setup(string camParamFile, string multiFile, int maxImagePatterns, int pattWidth, | ||
int pattHeight, int pattSamples, int maxLoadPatterns); | ||
|
||
int update(emscripten::val data_buffer); | ||
|
||
|
||
emscripten::val getMVMatrix(); | ||
|
||
int getMarkerId(); | ||
|
||
emscripten::val getMarkerPos(); | ||
|
||
emscripten::val getMarkerVertexes(); | ||
|
||
bool setPixelFormat(PIXEL_FORMAT nFormat); | ||
|
||
PIXEL_FORMAT getPixelFormat(); | ||
|
||
emscripten::val getProjectionMatrix(); | ||
|
||
void printCameraSettings(); | ||
|
||
void setBorderWidth(ARFloat nFraction); | ||
|
||
void setMarkerMode(MARKER_MODE nMarkerMode); | ||
|
||
void setThreshold(int nValue); | ||
|
||
void setUndistortionMode(UNDIST_MODE nMode); | ||
|
||
private: | ||
bool useBCH; | ||
int mWidth; | ||
int mHeight; | ||
int mPatternWidth; | ||
vector<int> mMarkers; | ||
ARMarkerInfo *marker_info; | ||
int marker_num; | ||
unique_ptr<ARToolKitPlus::TrackerMultiMarker> tracker; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i had troble loading both files, now i will develop my init function:
in this commit only load the camera but we can load the multi file and calib file separately.