JSARToolKit icon indicating copy to clipboard operation
JSARToolKit copied to clipboard

FLARSingleMarkerDetector Error

Open greatxam opened this issue 12 years ago • 9 comments

Hi,

I got an error when I use custom marker. What I did is this:

var encoder = new FLARIdMarkerDataEncoder_RawBit(); var oReq = new XMLHttpRequest(); oReq.onload = function(e) { var markerCode = new FLARCode(16,16); markerCode.loadARPatt(oReq.response);

encoder.encode(markerCode,encoder.createDataInstance());
detector = new FLARSingleMarkerDetector(param, markerCode,80);

} oReq.open("get", "pattern/custom_marker.pat", true); oReq.send();

And on my render() function:

function render() { var isDetected = detector.detectMarkerLite(raster,90); // error triggers here ... }

Uncaught TypeError: Cannot read property 'length' of undefined JSARToolKit.js:137 c JSARToolKit.js:137 ASKlass.detectMarkerLite JSARToolKit.js:12100

I hope someone can help me with this. And thanks in advance.

greatxam avatar Jan 21 '14 08:01 greatxam

Do you already found a solution for creating custom markers? I'm also working on an AR project and would realy appreciate your solution.

Thanks a lot!

Phil23 avatar May 12 '14 14:05 Phil23

No I haven't find a solution. But there a Flash (as3) version that works using SingleMarkerDetector.

greatxam avatar May 13 '14 09:05 greatxam

I got it working. I just looked at the AS file and adapted it to JS.

http://www.libspark.org/svn/js/JSARToolKit/trunk/src/JSAR.as

Phil23 avatar May 13 '14 13:05 Phil23

Hello Phil23 I just want to know if you've already found a solution to create your custom marker with JSARToolKit? Thank you

yuccai avatar Jul 10 '14 13:07 yuccai

Hey,

yes, i finally got it to work. I found an example from the original java library and adapted it to javascript. But i had to fix some bugs in the JSARToolKit to make it work, which was hard to figure out. I did not find the time to commit my changes yet.

Phil23 avatar Jul 11 '14 10:07 Phil23

Hi all,

The problem was in detectMarkerLite under FLARSingleMarkerDetector, in JSARToolKit.js.

1st. On line 12098 FLARRasterFilter_Threshold was not instantiated and is not needed

detectMarkerLite : function(i_raster,i_threshold)
  {
    FLARRasterFilter_Threshold(this._tobin_filter).setThreshold(i_threshold);
    //サイズチェック
    if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(i_raster.getSize())){
      throw new FLARException();
    }
    //ラスタを2値イメージに変換する.
...

should be:

detectMarkerLite : function(i_raster,i_threshold)
  {
    this._tobin_filter.setThreshold(i_threshold);
    //サイズチェック
    if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(i_raster.getSize())){
      throw new FLARException();
    }
    //ラスタを2値イメージに変換する.
...

2nd. On line 9841 BUFFER_FORMAT was not accessible

isEqualBufferType : function(i_type_value)
  {
    return BUFFER_FORMAT==i_type_value;
  }

should be:

isEqualBufferType : function(i_type_value)
  {
    return this.BUFFER_FORMAT==i_type_value;
  }

Custom markers now work for me! I-ll file pull request later today if someone want it compiled.

Cheers!

duxan avatar Jul 02 '15 10:07 duxan

Awesome, thanks!

On 2 July 2015 at 11:41, Dušan Ranđelović [email protected] wrote:

Hi all,

The problem was in detectMarkerLite under FLARSingleMarkerDetector, in JSARToolKit.js.

  1. On line 12098 FLARRasterFilter_Threshold was not instantiated and is not needed

detectMarkerLite : function(i_raster,i_threshold) { FLARRasterFilter_Threshold(this._tobin_filter).setThreshold(i_threshold); //サイズチェック if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(i_raster.getSize())){ throw new FLARException(); } //ラスタを2値イメージに変換する. ...

should be:

detectMarkerLite : function(i_raster,i_threshold) { this._tobin_filter.setThreshold(i_threshold); //サイズチェック if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(i_raster.getSize())){ throw new FLARException(); } //ラスタを2値イメージに変換する. ...

  1. On line 9841 BUFFER_FORMAT was not accessible

isEqualBufferType : function(i_type_value) { return BUFFER_FORMAT==i_type_value; }

should be:

isEqualBufferType : function(i_type_value) { return this.BUFFER_FORMAT==i_type_value; }

Custom markers work for me! I-ll file pull request later today if someone want it compiled.

Cheers!

— Reply to this email directly or view it on GitHub https://github.com/kig/JSARToolKit/issues/11#issuecomment-117994983.

Ilmari Heikkinen

web http://fhtr.net | mail [email protected] | skype ilmarihe tel (UK) +447427139588

FHTR Ltd Company Number. 8157370 Registered in England

kig avatar Jul 02 '15 10:07 kig

Hi @duxan, Thanks for it, I have try but didn't get any success can you please share a demo project which have custom marker please share or suggestion

rawatrob avatar Jan 17 '17 09:01 rawatrob

@rawatrob see https://github.com/kig/JSARToolKit/issues/9

kalwalt avatar Mar 24 '18 17:03 kalwalt