jeromeetienne / AR.js

Efficient Augmented Reality for the Web - 60fps on mobile!
MIT License
15.79k stars 2.22k forks source link

Modifying thickness/width of the marker borders #296

Closed Angelo8828 closed 5 years ago

Angelo8828 commented 6 years ago

Hello, I'm currently working on an AR project and the client requested to reduce the border size from the current 25% to 20%. Is it possible to modify the current border dimension for markers? If possible, then how to modify it? Thanks

javismiles commented 6 years ago

to design the border, I made the border on each side 1/10th of the inner area, as its 0.9 pattt ratio, which I also set through the software, but not being recognized so far...

javismiles commented 6 years ago

so hopefully im getting closer, so the .pat file is generated like this:

artoolkitx_genMarkerSet --pattRatio 0.9 -dpi=72 p9.jpg Reading JPEG file... Done. JPEG image 'p9.jpg' is 1300x1300. Pass 1: detected 3 marker candidates. Pass 2: 1 detected marker candidates are square. 1300x1300 input image will display in 1280x720 window at 55.4% size Saved pattern file 'p9-00.pat'. -- p9-00.pat -- Upper-left: {99.000000, 99.000000} Upper-right: {1200.000000, 99.000000} Lower-right: {1200.000000, 1200.000000} Lower-left: {99.000000, 1200.000000}

cool, but its .pat , not .patt like the ones I always use till now

and it doesnt work so far with the graphic I put you above

javismiles commented 6 years ago

I think the 0.9 border wasnt right, i think this is the right one p15

so now, doing it with that one I get

artoolkitx_genMarkerSet --pattRatio 0.9 -dpi=72 p15.jpg Reading JPEG file... Done. JPEG image 'p15.jpg' is 1300x1300. Pass 1: detected 4 marker candidates. Pass 2: 1 detected marker candidates are square. 1300x1300 input image will display in 1280x720 window at 55.4% size Saved pattern file 'p15-00.pat'. -- p15-00.pat -- Upper-left: {145.000000, 145.000000} Upper-right: {1154.000000, 145.000000} Lower-right: {1154.000000, 1154.000000} Lower-left: {145.000000, 1154.000000}

and the selection shown is this one p15result

is that correct?

javismiles commented 6 years ago

but its still not working, not being recognized, this is the pat file generated

0 0 0 0 90 240 255 255 255 255 255 255 255 255 255 255 0 0 0 95 255 255 255 255 255 255 255 255 255 255 255 255 0 0 111 255 255 255 255 255 255 255 255 255 255 255 255 255 0 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 202 151 254 255 255 255 255 255 255 255 255 255 255 255 255 163 1 0 159 255 255 255 255 255 255 255 255 255 255 254 159 0 0 0 0 162 255 255 255 255 255 255 255 255 243 140 0 0 0 0 0 90 254 255 255 255 255 255 255 239 48 0 0 0 0 0 95 255 255 255 255 255 255 255 239 47 0 0 0 0 0 99 255 255 255 255 255 255 255 212 30 0 0 0 0 0 156 255 255 255 255 255 255 255 207 16 0 0 0 0 0 0 0 90 240 255 255 255 255 255 255 255 255 255 255 0 0 0 95 255 255 255 255 255 255 255 255 255 255 255 255 0 0 111 255 255 255 255 255 255 255 255 255 255 255 255 255 0 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 202 151 254 255 255 255 255 255 255 255 255 255 255 255 255 163 1 0 159 255 255 255 255 255 255 255 255 255 255 254 159 0 0 0 0 162 255 255 255 255 255 255 255 255 243 140 0 0 0 0 0 90 254 255 255 255 255 255 255 239 48 0 0 0 0 0 95 255 255 255 255 255 255 255 239 47 0 0 0 0 0 99 255 255 255 255 255 255 255 212 30 0 0 0 0 0 156 255 255 255 255 255 255 255 207 16 0 0 0 0 0 0 0 90 240 255 255 255 255 255 255 255 255 255 255 0 0 0 95 255 255 255 255 255 255 255 255 255 255 255 255 0 0 111 255 255 255 255 255 255 255 255 255 255 255 255 255 0 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 202 151 254 255 255 255 255 255 255 255 255 255 255 255 255 163 1 0 159 255 255 255 255 255 255 255 255 255 255 254 159 0 0 0 0 162 255 255 255 255 255 255 255 255 243 140 0 0 0 0 0 90 254 255 255 255 255 255 255 239 48 0 0 0 0 0 95 255 255 255 255 255 255 255 239 47 0 0 0 0 0 99 255 255 255 255 255 255 255 212 30 0 0 0 0 0 156 255 255 255 255 255 255 255 207 16 0 0 0

255 255 255 255 255 255 255 255 255 255 255 243 48 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 239 47 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 239 30 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 212 16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 207 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 162 90 255 255 255 240 255 255 255 255 255 255 255 255 254 159 0 0 95 255 255 90 255 255 255 255 255 255 255 255 151 0 0 0 0 99 255 0 95 255 255 255 255 255 255 255 202 1 0 0 0 0 156 0 0 111 255 255 255 255 255 255 255 163 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 254 140 0 0 0 255 255 255 255 255 255 255 255 255 255 255 243 48 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 239 47 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 239 30 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 212 16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 207 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 162 90 255 255 255 240 255 255 255 255 255 255 255 255 254 159 0 0 95 255 255 90 255 255 255 255 255 255 255 255 151 0 0 0 0 99 255 0 95 255 255 255 255 255 255 255 202 1 0 0 0 0 156 0 0 111 255 255 255 255 255 255 255 163 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 254 140 0 0 0 255 255 255 255 255 255 255 255 255 255 255 243 48 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 239 47 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 239 30 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 212 16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 207 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 162 90 255 255 255 240 255 255 255 255 255 255 255 255 254 159 0 0 95 255 255 90 255 255 255 255 255 255 255 255 151 0 0 0 0 99 255 0 95 255 255 255 255 255 255 255 202 1 0 0 0 0 156 0 0 111 255 255 255 255 255 255 255 163 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 254 140 0 0 0

0 0 0 16 207 255 255 255 255 255 255 255 156 0 0 0 0 0 30 212 255 255 255 255 255 255 255 99 0 0 0 0 0 47 239 255 255 255 255 255 255 255 95 0 0 0 0 0 48 239 255 255 255 255 255 255 254 90 0 0 0 0 0 140 243 255 255 255 255 255 255 255 255 162 0 0 0 0 159 254 255 255 255 255 255 255 255 255 255 255 159 0 1 163 255 255 255 255 255 255 255 255 255 255 255 255 254 151 202 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 0 255 255 255 255 255 255 255 255 255 255 255 255 255 111 0 0 255 255 255 255 255 255 255 255 255 255 255 255 95 0 0 0 255 255 255 255 255 255 255 255 255 255 240 90 0 0 0 0 0 0 0 16 207 255 255 255 255 255 255 255 156 0 0 0 0 0 30 212 255 255 255 255 255 255 255 99 0 0 0 0 0 47 239 255 255 255 255 255 255 255 95 0 0 0 0 0 48 239 255 255 255 255 255 255 254 90 0 0 0 0 0 140 243 255 255 255 255 255 255 255 255 162 0 0 0 0 159 254 255 255 255 255 255 255 255 255 255 255 159 0 1 163 255 255 255 255 255 255 255 255 255 255 255 255 254 151 202 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 0 255 255 255 255 255 255 255 255 255 255 255 255 255 111 0 0 255 255 255 255 255 255 255 255 255 255 255 255 95 0 0 0 255 255 255 255 255 255 255 255 255 255 240 90 0 0 0 0 0 0 0 16 207 255 255 255 255 255 255 255 156 0 0 0 0 0 30 212 255 255 255 255 255 255 255 99 0 0 0 0 0 47 239 255 255 255 255 255 255 255 95 0 0 0 0 0 48 239 255 255 255 255 255 255 254 90 0 0 0 0 0 140 243 255 255 255 255 255 255 255 255 162 0 0 0 0 159 254 255 255 255 255 255 255 255 255 255 255 159 0 1 163 255 255 255 255 255 255 255 255 255 255 255 255 254 151 202 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 255 255 255 255 255 255 255 255 255 255 255 255 255 255 159 0 255 255 255 255 255 255 255 255 255 255 255 255 255 111 0 0 255 255 255 255 255 255 255 255 255 255 255 255 95 0 0 0 255 255 255 255 255 255 255 255 255 255 240 90 0 0 0 0

0 0 0 140 254 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 163 255 255 255 255 255 255 255 111 0 0 156 0 0 0 0 1 202 255 255 255 255 255 255 255 95 0 255 99 0 0 0 0 151 255 255 255 255 255 255 255 255 90 255 255 95 0 0 159 254 255 255 255 255 255 255 255 255 240 255 255 255 90 162 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 207 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 16 212 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 30 239 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 47 239 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 48 243 255 255 255 255 255 255 255 255 255 255 255 0 0 0 140 254 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 163 255 255 255 255 255 255 255 111 0 0 156 0 0 0 0 1 202 255 255 255 255 255 255 255 95 0 255 99 0 0 0 0 151 255 255 255 255 255 255 255 255 90 255 255 95 0 0 159 254 255 255 255 255 255 255 255 255 240 255 255 255 90 162 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 207 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 16 212 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 30 239 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 47 239 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 48 243 255 255 255 255 255 255 255 255 255 255 255 0 0 0 140 254 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 159 255 255 255 255 255 255 255 159 0 0 0 0 0 0 0 0 163 255 255 255 255 255 255 255 111 0 0 156 0 0 0 0 1 202 255 255 255 255 255 255 255 95 0 255 99 0 0 0 0 151 255 255 255 255 255 255 255 255 90 255 255 95 0 0 159 254 255 255 255 255 255 255 255 255 240 255 255 255 90 162 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 207 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 16 212 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 30 239 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 47 239 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 48 243 255 255 255 255 255 255 255 255 255 255 255

ThorstenBux commented 6 years ago

I'll check. Could you share the app you use to verify if the marker works?

btw. patt and pat is the same.

javismiles commented 6 years ago

thank you thorsten, Im not using any special app, im on purpose using the marker with the most basic example possible, straight of the demos of ar.js, on purpose as simple as possible to verify if the change of ratio works

javismiles commented 6 years ago

thats why the essence of the code is extremely simple, ok unfortunately it wont paste it correctly here, its the same anyway, same as any super simple tutorial demo of ar.js, the simplest thing possible with the only change of the patt ratio, thats all

`

</a-scene>`
ThorstenBux commented 6 years ago

Sorry, can't say anything in regards to AR.js I'm only using ARToolKit directly and the desktop version can deal with different border sizes.

javismiles commented 6 years ago

oooh that's a pity, well, in theory it should work in Ar.js, in theory... but.. mmm...

derzu commented 6 years ago

Is it possible to set the border to zero and let the image be 100% of the marker?

ThorstenBux commented 6 years ago

@derzu the border is used to detect the markers, meaning they are needed. What you would need is the NFT feature that detects JPG files in the video stream. But that does not run performantly on mobile and hasn't been merged into the master branch of artoolkit.

derzu commented 6 years ago

@ThorstenBux thanks for the reply, yes I wanna an NFT (Natural Feature Tracking) marker. I have an algorithm in mind that I think can be fast enough to have a great performance on mobile browsers.

Do you know where in the artookit is exactly the function that does the pixel comparison? Or where on the AR.js can this function be replaced?

ThorstenBux commented 6 years ago

AR.js is just a JS layer on top of jsartoolkit5 which in turn is a transpilation of ARToolKit5 which is a C/C++ library. Or in short, if you would like to implement anything then you need to do it in C.

If you are still up to it then I can guide you to the corresponding lines. If you would like to implement something purely JS based I think the base place to start is OpenCV.js and go from there. But that would mean to start from scratch.

derzu commented 6 years ago

@ThorstenBux, thanks again for the reply. I think I found where the marker detection is done:

On the file: jsartoolkit5/js/artoolkit.api.js, the function ARController.prototype.detectMarker() This function calls the C++ method detectMarker() from the file: jsartoolkit5/emscripten/ARToolKitJS.cpp

This c++ method calls the arDetectMarker() method, I don't know from where.

I will try to overwrite the ARController.prototype.detectMarker() on JavaScript, if I got success on my code I can port it to a faster c++ version. I think I don't need the OpenCV.js, just the pixels from the video and from the marker are enough.

Can you confirm if I'm looking at the right functions?

I intend to overwrite the detectMarker() getting the window.ARController.

GospelNerd commented 5 years ago

@derzu found this thread while Googling around on this topic. Have you made any progress on your idea here?

nicolocarpignoli commented 5 years ago

I think no issues is being discussed here, at the moment. I close