[UWP]在c#uwp中实现C ++控制台应用程序 [英] [UWP]Implementing C++ console application in c# uwp

查看:212
本文介绍了[UWP]在c#uwp中实现C ++控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在uwp c#中创建了一个应用程序,并希望实现使用opencv技术在c ++中创建的图像比较方法(http://www.codeproject.com/Articles/24809/Image -Alignment-Algorithms)。我遇到了以下障碍

 i have created an app in uwp c# and wanted to implement image comparison method  which has been created in c++ using opencv Technology(http://www.codeproject.com/Articles/24809/Image-Alignment-Algorithms).i come across following hurdles

1.这种图像对齐算法仅适用于x64平台。它也适用于ARM和x86模式。

1.This image alignment algorithms works only for x64 platform.It should work on ARM and x86 mode also.

2.我有一个在uwp上使用opencv的参考(http://osconqsc2015.azurewebsites.net/qsccontent/opencv/opencv.html),但目前尚不清楚。

2.I got  one reference for using opencv on uwp (http://osconqsc2015.azurewebsites.net/qsccontent/opencv/opencv.html) but it is not clear .

我的图像对齐算法工作正常,这是用c ++创建的,我在uwp c#上的应用程序也正常工作。我想使用c ++控制台图像对齐

my image alignment algorithm is working properly which is created in c++, and my app on uwp c# is also working properly .i want to use that c++ console image alignment

功能我的c#uwp。如何实现这一点。

feature in my c# uwp .how to achieve that.

推荐答案

嗨pariwesh,



[2016年3月30日更新]欢迎来到开发通用Windows应用程序论坛!

请阅读粘贴帖子,尤其是
发布指南:主题行标签

Windows 10 SDK和工具的已知问题




据我所知,您可以通过在UWP解决方案中使用Windows运行时组件包装C ++代码并从C#项目调用它来实现这一目的。 

如何使用C ++创建Windows运行时组件,您可以参考以下链接。

https://msdn.microsoft.com/en-us/library/hh441 569.aspx

有关将"Windows运行时类型"传递给C#托管项目的内容,可以参考以下链接。

https://msdn.microsoft.com/en-us/library/br230301.aspx

如何在UWP
应用程序中使用现有的C ++代码,可以参考以下链接。 

https://msdn.microsoft .com / zh-cn / library / mt186162.aspx

创建Windows运行时组件后,需要更改预编译的头文件设置,包括目录和库,就像在控制台应用。对于Visual Studio 2015,您可以参考以下步骤:

Windows运行时组件 - >属性 - >配置属性 - > C / C ++ - >预编译标题 - >预编译标题 - > [如果需要,选择"不使用预编译标题"]

Windows运行时组件 - >属性 - >配置属性 - > C / C ++ - >一般 - >其他包含目录 - > [添加三个包含目录]

Windows运行时组件 - >属性 - >配置属性 - >链接器 - >一般 - >其他图书馆目录 - > [添加库目录]

Windows运行时组件 - >属性 - >配置属性 - >链接器 - >输入 - >附加依赖性 - > [添加三个库]

然后你需要将"cv100.dll,cxcore100.dll,highgui100.dll,libguide40.dll"(位于OpenCV \ bin)添加到UWP C#项目中通过"右键单击项目并添加现有项目"。

将Windows运行时组件的引用添加到C#项目后,您的解决方案可能会编译,它可能看起来像下面的屏幕截图。

Hi pariwesh,

[Updated 3/30/2016]Welcome to the Developing Universal Windows apps forum!
Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools

As far as I know, you could achieve that by wrapping the C++ code with a Windows Runtime Component in your UWP solution and calling it from C# project. 
For how to create a Windows Runtime Component in C++, you could refer to the following link.
https://msdn.microsoft.com/en-us/library/hh441569.aspx
For something about passing "Windows Runtime types" to your C# managed project, you could refer to the following link.
https://msdn.microsoft.com/en-us/library/br230301.aspx
For how to use existing C++ Code in a UWP app, you could refer to the following link. 
https://msdn.microsoft.com/en-us/library/mt186162.aspx
After creating the Windows Runtime Component, you need to change the precompiled header setting, include the directories and libs as you do in the console application. For Visual Studio 2015, you could refer to the following steps.
Windows Runtime Component -> Properties -> Configuration Properties -> C/C++ -> Precompiled Headers -> Precompiled Header -> [choose "Not Using Precompiled Headers" if needed]
Windows Runtime Component -> Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories -> [add the three include directories]
Windows Runtime Component -> Properties -> Configuration Properties -> Linker -> General -> Additional Library Directories -> [add the library directory]
Windows Runtime Component -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> [add the three libs]
Then you need to add the "cv100.dll, cxcore100.dll, highgui100.dll, libguide40.dll"(located at OpenCV\bin) to the UWP C# project by "right-click the project and add existing item".
After adding reference of the Windows Runtime Component to the C# project, your solution may compile and it may looks like the following screenshot.


这篇关于[UWP]在c#uwp中实现C ++控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆