2017-03-06 15 views
0

私はWikitude AR SDKの簡単な画像認識に取り組んでいます。 私はJavascript SDKを使用しており、サンプルプロジェクト "01_ImageRecognition_1_ImageOnTarget"を開始しました。 コードは次のようである:私は認識されている撮影画像の一部をトリミングすることを目的とWikitudeの切り抜き画像の切り取り

var World = { 
    loaded: false, 

    init: function initFn() { 
     this.createOverlays(); 
    }, 

    createOverlays: function createOverlaysFn() { 
     /* 
      First an AR.ImageTracker needs to be created in order to start the recognition engine. It is initialized with a AR.TargetCollectionResource specific to the target collection that should be used. Optional parameters are passed as object in the last argument. In this case a callback function for the onTargetsLoaded trigger is set. Once the tracker loaded all its target images, the function worldLoaded() is called. 

      Important: If you replace the tracker file with your own, make sure to change the target name accordingly. 
      Use a specific target name to respond only to a certain target or use a wildcard to respond to any or a certain group of targets. 
     */ 
     this.targetCollectionResource = new AR.TargetCollectionResource("assets/bp2.wtc", { 
     }); 

     this.tracker = new AR.ImageTracker(this.targetCollectionResource, { 
      onTargetsLoaded: this.worldLoaded 
     }); 

     /* 
      The next step is to create the augmentation. In this example an image resource is created and passed to the 
      AR.ImageDrawable. A drawable is a visual component that can be connected to an IR target (AR.ImageTrackable) 
      or a geolocated object (AR.GeoObject). The AR.ImageDrawable is initialized by the image and its size. 
      Optional parameters allow for position it relative to the recognized target. 
     */ 

     /* Create overlay for page one */ 
     var imgOne = new AR.ImageResource("assets/imageOne.png"); 
     var overlayOne = new AR.ImageDrawable(imgOne, 1, { 
      translate: { 
       x:-0.15 
      } 

     }); 

     /* 
      The last line combines everything by creating an AR.ImageTrackable with the previously created tracker, the name of the image target and the drawable that should augment the recognized image. 
      Please note that in this case the target name is a wildcard. Wildcards can be used to respond to any target defined in the target collection. If you want to respond to a certain target only for a particular AR.ImageTrackable simply provide the target name as specified in the target collection. 
     */ 
     var pageOne = new AR.ImageTrackable(this.tracker, "*", { 
      drawables: { 
       cam: overlayOne 
      } 
     }); 
    }, 

    worldLoaded: function worldLoadedFn() { 

     var cssDivLeft = " style='display: table-cell;vertical-align: middle; text-align: right; width: 50%; padding-right: 15px;'"; 
     var cssDivRight = " style='display: table-cell;vertical-align: middle; text-align: left;'"; 
     document.getElementById('loadingMessage').innerHTML = 
      "<div" + cssDivLeft + ">Scan Target &#35;1 (surfer):</div>" + 
      "<div" + cssDivRight + "><img src='assets/bp.png'></img></div>"; 

     // Remove Scan target message after 10 sec. 
     setTimeout(function() { 
      var e = document.getElementById('loadingMessage'); 
      e.parentElement.removeChild(e); 
     }, 10000); 
    } 
}; 
World.init(); 

。 私はWikitude Forumで尋ねましたが、誰も私を案内してくれなかったので、関連する文書を見つけることができませんでした。 誰かが私を助けてくれることを願っています。

答えて

1

Wikitude Javascript SDKで何を求めているのかを確認するには、単純なプラグインを作成する必要があります。 Javascript SDK自体は、この種の機能を提供していません。

cameraFrameAvailable関数の現在のカメラフレームと、update関数で現在認識されているターゲットのリストが表示されます。前者は現在のカメラフレームの画素バッファへのポインタへのアクセスを提供し、後者は前述のフレーム内の認識された画像ターゲットの座標を提供する。

void Plugin::cameraFrameAvailable(const wikitude::sdk::Frame& cameraFrame_) 

void Plugin::update(const std::list<wikitude::sdk::RecognizedTarget>& recognizedTargets_) 

これらの2つの機能が同時に実行されるため、競合状態に注意し、それに応じてデータへのアクセスを同期する必要があります。

プラグインを作成する方法の詳細、hereなど、対応するドキュメントページがあります。

あなたは、あなたが数時間以内にWikitudeフォーラムに投稿した質問に対する回答を受け取ったことを強調したいと思います。必要がある場合は、さらにサポートを提供しています。

関連する問題