Tag: c ++

将Texture2D转换为OpenCV Mat?

在Unity中有一篇关于将OpenCV cv::Mat转换为Texture2D的post ,我提供了一个效果很好的答案。 现在,我正试图做相反的事情,但现在已经坚持了几个小时。 我想将Unity的Texture2D转换为OpenCV cv::Mat以便我可以在C ++端处理Texture。 这是我想要转换为cv:Mat Unity项目中的原始Texture2D : 这是将它转换为cv:Mat后的样子cv:Mat : 它看起来很褪色。 我并不担心图像的旋转 。 我可以解决这个问题。 只是想知道为什么它看起来如此褪色。 还使用cv::imwrite保存图像以用于测试目的,但问题也出现在保存的图像中。 C#代码 : [DllImport(“TextureConverter”)] private static extern float TextureToCVMat(IntPtr texData, int width, int height); unsafe void TextureToCVMat(Texture2D texData) { Color32[] texDataColor = texData.GetPixels32(); //Pin Memory fixed (Color32* p = texDataColor) { TextureToCVMat((IntPtr)p, texData.width, texData.height); } } public Texture2D […]

WinRt页面导航

如何从自定义类内部的代码导航到页面。 例如,假设我在MainPage.xaml.cs中有这个代码: private void DoSomething(object sender, RoutedEventArgs e) { var work = new Work(); work.doMore(); } 在这个课程中,我希望导航实际发生在这里: public class Work { public void DoMore() { // this is what I’ve tried, but doesn’t work var myFrame = new Frame(); myFrame.Navigate(typeof(HomePage)); } }

阅读csv文件客户端

我必须阅读csv文件客户端的前几行,以便在上传大文件之前向用户显示预览。 我在ASP.Net(VS2010)上使用c# 有谁知道如何做到这一点? 它也适用于所有浏览器!?! (不可能使用activeX左右,我们不希望我们的客户安装东西!) 示例代码会很棒! 提前致谢!

如何从Native组件进行函数调用或触发事件到C#/ XAML组件?

我正在开发一个带有Native(DirectX / D3D)组件和C#/ XAML组件的WP8应用程序。 Native组件绘制到UI元素,C#/ XAML组件具有围绕它的app(和其他东西)的控件。 通常,我将信息从C#/ XAML组件发送到Native组件。 但是有些时候我想根据在Native组件中完成处理的时间来触发C#/ XAML组件中的事件。 在一个计划的function中,我设想了一个C#/ XAML进度条,它通过Native组件中触发的事件保持最新。 不幸的是,尽管有一些平庸的尝试将信息从Native组件传递到C#/ XAML,但我没有取得太大进展,我感到死在水中。 我非常感谢任何指导。 谢谢阅读。

Subsonic 3 ActiveRecord嵌套选择NotIn bug?

我有以下Subsonic 3.0查询,其中包含嵌套的NotIn查询: public List GetRandomOrdersForNoReason(int shopId, int typeId) { // build query var q = new SubSonic.Query.Select().Top(“1”) .From(“Order”) .Where(“ShopId”) .IsEqualTo(shopId) .And(OrderTable.CustomerId).NotIn( new Subsonic.Query.Select(“CustomerId”) .From(“Customer”) .Where(“TypeId”) .IsNotEqualTo(typeId)) .OrderDesc(“NewId()”); // Output query Debug.WriteLine(q.ToString()); // returned typed list return q.ExecuteTypedList(); } 内部查询似乎不正确: SELECT TOP 1 * FROM [Order] WHERE ShopId = @0 AND CustomerId NOT IN (SELECT CustomerId […]

如何为DataGridViewTextBoxColumn设置Password属性

我已经使用DataGridView来实现用户名密码UI。 密码显示在DataGridViewTextBoxColumn类型列中。 如何使用DataGridViewTextBoxColumn的现有代码并实现文本的密码属性?

entity framework,getutcdate()

我可以使用entity framework中的SQL函数getutcdate()在保存实体对象时在数据库中设置日期字段吗? 关于弗雷迪

在循环中使用方法Marshal.PtrToStructure时访问冲突exception

在我的程序(C#)中,我使用方法Marshal.PtrToStructure转换对象在循环中添加内存地址到结构。 在第一个元素,这项工作是正常的。 但是在第二个元素处,发生访问冲突exception。 访问冲突exception仅在win 7(64位)上发生,在win xp(32位)上不会发生。 我不知道原因和解决方案。 请帮我。 注意:我使用.NET Framework 3.5。 代码如下: [StructLayout(LayoutKind.Sequential)] public struct gpc_vertex { public float x; public float y; }; private ArrayList DoPolygonOperation() { IntPtr currentVertex = vertexList.vertexes; gpc_vertex oVertext = new gpc_vertex(); for (int j = 0; j < vertexList.num_vertices; j++) { PositionF pos = new PositionF(); oVertext = (gpc_vertex)Marshal.PtrToStructure(currentVertex, […]

在C#中启动Windows服务

我想启动刚刚安装的Windows服务。 ServiceBase[] ServicesToRun; if (bool.Parse(System.Configuration.ConfigurationManager.AppSettings[“RunService”])) { ServicesToRun = new ServiceBase[] { new IvrService() }; ServiceBase.Run(ServicesToRun); } IvrService代码是: partial class IvrService : ServiceBase { public IvrService() { InitializeComponent(); Process myProcess; myProcess = System.Diagnostics.Process.GetCurrentProcess(); string pathname = Path.GetDirectoryName(myProcess.MainModule.FileName); //eventLog1.WriteEntry(pathname); Directory.SetCurrentDirectory(pathname); } protected override void OnStart(string[] args) { string sProcessName = Process.GetCurrentProcess().ProcessName; if (Environment.UserInteractive) { if (sProcessName.ToLower() != […]

c#中的C ++非托管DLL

我被要求在我的项目中集成网络摄像头ZoneTrigger。 该站点提供的SDK也是C ++的样本。 我已经能够使用很少的function。 我被卡住的地方是一个函数,其中char *是传递的参数。 我做了很多挖掘,并且已经知道必须使用MarshalAs …… 我想从c ++代码导入的函数 //header file struct ZT_TRIG_STRUCT { int aSize; //STRUCT size int CameraIndex; int SpotIndex; int SpotType; char SpotName[32]; DWORD Dummy[16]; }; typedef int (WINAPI *f_ZT_EnumerateHotSpots)(int SpotIndex, char *Name, int *SpotType); /* You application can call this functions to retrieve information about spots by iterating the SpotIndex […]