首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在xamarin表单中使用wikitude插件?

如何在xamarin表单中使用wikitude插件?
EN

Stack Overflow用户
提问于 2017-10-12 10:42:24
回答 1查看 206关注 0票数 2

我正在使用Xamarin开发跨平台的AR应用程序。我正在使用Wikitude即时跟踪。

我能够启动Wikitude活动,并能够运行即时tracking...Now --我希望在跟踪时捕获高分辨率图像.我正在尝试构建插件以获取帧,然后将其转换为图像流

她是我的维基活动

代码语言:javascript
复制
 namespace XamarinExample.Droid
    {
        [Activity(Label = "WikitudeActivity")]
        public class WikitudeActivity : Activity, ArchitectView.IArchitectUrlListener
        {
            ArchitectView architectView;
            string worldUrl;

            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);

                SetContentView(Resource.Layout.sample_cam);

                Title = Intent.GetStringExtra("id");

                worldUrl = "Wikitude" + File.Separator + Intent.GetStringExtra("id") + File.Separator + "index.html";

                architectView = FindViewById<ArchitectView>(Resource.Id.architectView);

                ArchitectStartupConfiguration startupConfiguration = new ArchitectStartupConfiguration();
                startupConfiguration.setLicenseKey(Constants.WIKITUDE_SDK_KEY);
                startupConfiguration.setFeatures(ArchitectStartupConfiguration.Features.ImageTracking);
                startupConfiguration.setCameraResolution(CameraSettings.CameraResolution.Auto);



/////////////////////////////// Register  Plugin////////////////////////////////////


                var plugins = new Plugin01("test");
                architectView.RegisterPlugin(plugins);

                architectView.OnCreate(startupConfiguration);
                architectView.RegisterUrlListener(this);
            }

    }

My Plugin code taken from

代码语言:javascript
复制
public class Plugin01 : Com.Wikitude.Common.Plugins.Plugin
 {
    public Plugin01(string p0) : base(p0)
    {

    }    
    Frame currentFrame = null;
    public override void CameraFrameAvailable(Frame p0)
    {
    System.Diagnostics.Debug.WriteLine("AVAILABLE FRAME");
        try
        {
            var data = p0.GetData();
            currentFrame = p0;
        }
        catch (System.Exception ex) { }
    }

    public override void Update(RecognizedTarget[] p0)
    {
            System.Diagnostics.Debug.WriteLine("AVAILABLE FRAME");
        if (p0 != null)
        {
            if (currentFrame != null)
            {
               // ConvertYuvToJpeg(currentFrame, p0[0]);
            }
        }
    }

}

我已经注册了插件,但它没有调用

公共覆盖无效更新(RecognizedTarget[] p0) Method....What在这里做错了吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-14 06:32:07

我认为问题是在错误的方法中调用"RegisterPlugin“,因为您知道调用活动方法的循环是different.you应该在"OnPostCreate”活动方法中调用它。尝试下面的代码并让我知道结果:

代码语言:javascript
复制
protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        try
        {
            SetContentView(Resource.Layout.Main);
            architectView = FindViewById<ArchitectView>(Resource.Id.architectView);
            var config = new ArchitectStartupConfiguration();
            config.setLicenseKey(WIKITUDE_SDK_KEY);
            architectView.OnCreate(config);
        }
        catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Long); }
    }

protected override void OnPostCreate(Bundle savedInstanceState)
    {
        base.OnPostCreate(savedInstanceState);
        if (architectView != null)
            architectView.OnPostCreate();
        try
        {
            try
            {
                string url = string.Format(@"file:///android_asset/01_ImageRecognition_1_ImageOnTarget/index.html");
                architectView.Load(url);
                Plugin01 cardPlugin = new Plugin01("com.plugin.dpiar");
                architectView.RegisterPlugin(cardPlugin);
            }
            catch (Exception ex) { }
        }
        catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Long); }
    }

考虑更改变量名。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46707586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档