Skip to content
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

Fix for custom marker problem (issue #164) #168

Closed
wants to merge 4 commits into from
Closed

Fix for custom marker problem (issue #164) #168

wants to merge 4 commits into from

Conversation

wimvdc
Copy link

@wimvdc wimvdc commented Aug 21, 2017

Fix for issue: #164

Added new if statement.
Example usage:
<a-marker-camera preset='custom' url='/my/path/mymarker.patt'></a-marker-camera>

Fix for issue: #164

Added new if statement.
Example usage: 
`<a-marker-camera preset='custom' url='/my/path/mymarker.patt'></a-marker-camera>
`
Modified documentation to match pull request #168 (which should be fix for issue #164
@jeromeetienne
Copy link
Owner

im not sure i understand.

Custom markers can be reached with type=pattern patternURL=/path/to/yourmarkers

Why doing a preset 'custom' which does the same thing ?

@wimvdc
Copy link
Author

wimvdc commented Aug 23, 2017

@jeromeetienne
Custom markers don't seem to work (see issue #164 and issue #127 )
If you check the "old" code there seems to be no way to reach:
arProfile.defaultMarkerParameters.patternUrl = /value/form/a-marker-camera/components.patt
which seems to be required to recognize the custom pattern. In other cases it defaults to the Hiro pattern.

@jeromeetienne
Copy link
Owner

jeromeetienne commented Aug 23, 2017 via email

Refactoring to make the custom marker work as intended
Reverted my changes
@wimvdc
Copy link
Author

wimvdc commented Aug 23, 2017

@jeromeetienne Yes you are right.
Added 2 commits. Revert for my documentation changes and modified the if statement so that we can use use type='pattern' instead of preset='custom'

@kumarahir
Copy link

hi @wimvdc following isn't working for me

<!-- include A-Frame obviously -->
<script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script>
<!-- include ar.js for A-Frame -->
<script src="https://jeromeetienne.github.io/AR.js/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'>
  <a-scene embedded arjs>
	<a-marker-camera type='pattern' patternUrl='kum.patt'>
		<a-box position='0 0 0' material='color: red;'></a-box>
	</a-marker-camera>
  </a-scene>
</body>

attached is the patt file (compressed)
kum.zip

@wimvdc
Copy link
Author

wimvdc commented Aug 29, 2017

@kumarahir You need build the source code from this PR (and thus my branch) yourself since the PR hasn't accepted yet.
You are using the current master branch code from Jerome so it's normal it isn't working for you.

@Noko-Noko
Copy link

Noko-Noko commented Sep 4, 2017

Hi @wimvdc thanks for the help so far, having the same issue here, using this PR and generating new files from this src, and when I try and run this I get this error
aframe-ar.js:4766 THREEx.ArMarkerControls: 'markersAreaEnabled' is not a property of this material. value @ a-assets.js:59 value @ a-register-element.js:150 aframe-ar.js:2 Pattern Data read error!! aframe-ar.js:2 loadMarker(): Error loading pattern file /marker_0. aframe-ar.js:2 ARToolKitJS(): Unable to set up AR marker. aframe-ar.js:2 Out of memory!!

Tried with a very simple marker and even had a go at the one posted by Kum, still the same error.

[update] OK seems to be that it does not find the .patt at all, tried with relative and absolute url and nothing, but hardcoding it on line 89 instead of using _this.data.patternUrl works fine

@wimvdc
Copy link
Author

wimvdc commented Sep 4, 2017

@Noko-Noko Seems like you definied your marker tag incorrect.
I'm using it a personal repo (1 custom pattern and hiro). You can find my page: https://github.com/wimvdc/Tradfri_AR/blob/master/public/index.html

@Noko-Noko
Copy link

@wimvdc I see, me and @kumarahir did the same "mistake" as we used what Jerome suggested, ie: patternURL="patth/to/.patt", but you are using just url="patth/to/.patt", and because on your amended js you are using _this.data.patternUrl so everything added up, but you are right just changing patternURL to url using your branch did the trick, cheers!

@KaareGravesen
Copy link

@wimvdc Thanks a bunch for that branch, my custom patterns also work now 😁

@mevanloon
Copy link

mevanloon commented Sep 11, 2017

@wimvdc many guides refer to the custom pattern attribute as patternUrl rather than just url, so it may be a good idea (if not only for clarity) to keep it at patternUrl.

But I too want to thank you for this branch! Helped me along too.

@zspringer
Copy link

I too cannot get the custom marker to work. Beyond that, any idea how to create a custom marker that could wouldn't have to be printed out but rather drawn on something? An example would be if I drew the "marker" on my hand and have the image show up there. Perhaps the marker could be like a smiley face... That is the angle I'm trying to go for but the only marker information I'm finding is for creating the "hiro" style markers with the big box etc... and having the physical marker printed out. Any help would be awesome!! Thanks

@wimvdc
Copy link
Author

wimvdc commented Sep 12, 2017

@mevanloon Thanks for the feedback. I'm following/respecting Jerome's documentation (see a-frame/README.MD). But I will check if it's possible to support them both.

@zspringer You always have to 'train' your markers. What you could do is make your drawing on paper, scan it (or take a decent picture) and train it. That way you have the .patt file to use in your code but you still have your own drawing on paper.

@mevanloon
Copy link

@zspringer I'm afraid the black box is needed. The black box is the best way of keeping AR content in view as much as possible.

@zspringer
Copy link

Yeah, I'm finding that out just now which is a bummer. ar.js doesn't support borderless markers as of now. I've seen apps that use markers that can be hand drawn and the marker is recognized (example: draw a basic smiley face on your hand) but I have no idea what type of tech they are using to do so. Ideas?

@JoeBerkley
Copy link

Is there an eta on this being merged?

@ronilitman
Copy link

@wimvdc @Noko-Noko How did you guys generate new files from this PR without the build process?

@wimvdc
Copy link
Author

wimvdc commented Oct 25, 2017

@ronilitman Not. I used the provided build 'tools'

@KaareGravesen
Copy link

I created .patt files via this page:
https://jeromeetienne.github.io/AR.js/three.js/examples/marker-training/examples/generator.html

Works perfectly.

@rondagdag rondagdag mentioned this pull request Oct 27, 2017
@bethannezink
Copy link

Hey @jeromeetienne! Love this tool -- it's been very helpful to me in my new explorations with Web AR. I'm currently working on adapting a custom marker myself, and I've reached the same conclusion that the folks above have reached. Could this PR get merged soon?

@cwervo
Copy link
Collaborator

cwervo commented Nov 9, 2017

Ah, custom markers have been broken since about the last major rewrite @jeromeetienne this would be great to get merged soon. #236 looks like it also gets to the root of the problem!

@LeviBerciu
Copy link

Hi @jeromeetienne, awesome tool! I'm very new to coding in general. I'm trying to get custom markers to work. I tried a lot of things but I had no success.
Now I am trying to use @wimvdc 's "patch-1" branch but it only works with Hiro marker. @KaareGravesen how did you fix this issue?

I used this generator to create my .patt file:
https://jeromeetienne.github.io/AR.js/three.js/examples/marker-training/examples/generator.html

<html>
  <head>
    <script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>
    <script src="https://rawgit.com/wimvdc/ar.js/patch-1/aframe/build/aframe-ar.js"></script>
  </head>
  <body>
    <a-scene embedded artoolkit="sourceType: webcam" vr-mode-ui="enabled: false" arjs="trackingMethod: best; debugUIEnabled: false;">
      <a-marker type='pattern' url='wolf.patt'>
        <a-box position='0 0.5 0' material='color: #fff; opacity: 0.5'></a-box>
      </a-marker>
      <a-entity camera></a-entity>
    </a-scene>
  </body>
</html>

Thanks! Any help is welcome :)

@javismiles
Copy link

javismiles commented Nov 16, 2017 via email

@mattGraphics
Copy link

Does anyone know if the custom marker issue is resolved?

I've been trying for a few weeks with the many solutions offered across the web, but have found some comments that say custom markers still don't work as of Feb 2018. I see this guy ( https://github.com/u4bi-git/simple-ar.js ) got it to work, but that was Sept '17 and the problem seems to be more recent.

Every video on youtube uses just the Hiro marker.

Shouldn't it work if I just add the custom marker code below to Jerome's codepen: https://codepen.io/jeromeetienne/pen/mRqqzb

<a-marker preset='custom' type='pattern' url='pattern-marker.patt'>
	    
<a-text anchor="align" position="0 0.1 0" rotation="270 0 0" side="double" width="5" color="red" value="hello world"></a-text>
	</a-marker>

@PohlodSlavik
Copy link

Hi @mattGraphics, actually issue with the custom marker is not resolved in the main branch, but you could find a working fix in the commits tab above.

@mattGraphics
Copy link

Many thanks @PohlodSlavik - I've tried the solutions offered, but nothing worked for me. it looks like it was merged by Jerome 4 days ago:

#236

but still doesn't work for me. I'll wait until I hear if it works for everyone else, then at least I know it's something I'm doing wrong :-)

@wimvdc
Copy link
Author

wimvdc commented Mar 15, 2018

A newer PR with the exact same code changes was accepted instead of this one, should work now.

@wimvdc wimvdc closed this Mar 15, 2018
@dokato dokato mentioned this pull request Jul 2, 2018
@PedroNan
Copy link

PedroNan commented Sep 30, 2020

I don't understand what is the problem with custom markers. Using the example of the attached code it works perfectly, with the native marker. But trying to use a custom markers doesn't work. Please help.

`<html>
  <head>
    <script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
    <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
    <script src="https://raw.githack.com/AR-js-org/studio-backend/master/src/modules/marker/tools/gesture-detector.js"></script>
    <script src="https://raw.githack.com/AR-js-org/studio-backend/master/src/modules/marker/tools/gesture-handler.js"></script>
    <script>
      AFRAME.registerComponent("videohandler", {
        init: function() {
          var marker = this.el;
          this.vid = document.querySelector("#vid");

          marker.addEventListener(
            "markerFound",
            function() {
              this.toggle = true;
              this.vid.play();
            }.bind(this)
          );

          marker.addEventListener(
            "markerLost",
            function() {
              this.toggle = false;
              this.vid.pause();
            }.bind(this)
          );
        }
      });
    </script>
  </head>

  <body style="margin: 0; overflow: hidden;">
    <a-scene
      vr-mode-ui="enabled: false"
      loading-screen="enabled: false;"
      arjs="sourceType: webcam; debugUIEnabled: false;"
      id="scene"
      embedded
      gesture-detector
    >
      <a-assets>
        <video
          id="vid"
          src="https://cdn.glitch.com/b5f96dca-fbbc-4c81-8091-19fbaf01c314%2Fasset.mp4?v=1599009994056"
          preload="auto"
          response-type="arraybuffer"
          loop
          crossorigin
          webkit-playsinline
          autoplay
          muted
          playsinline
        ></video>
      </a-assets>

      <a-marker
        type="pattern"
        preset="custom"
        url="https://cdn.glitch.com/b5f96dca-fbbc-4c81-8091-19fbaf01c314%2Fmarker.patt?v=1599009800978"
        videohandler
        smooth="true"
        smoothcount="10"
        smoothtolerance="0.01"
        smooththreshold="5"
        raycaster="objects: .clickable"
        emitevents="true"
        cursor="fuse: false; rayOrigin: mouse;"
        id="markerA"
      >
        <a-video
          src="#vid"
          scale="1 1 1"
          position="0 0.1 0"
          rotation="-90 0 0"
          class="clickable"
          gesture-handler
        ></a-video>
      </a-marker>

      <a-entity camera></a-entity>
    </a-scene>
  </body>
</html>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.