C#Interp。用于C ++中的活动形状模型库 [英] C# Interp. for Active Shape Models library in C++

查看:294
本文介绍了C#Interp。用于C ++中的活动形状模型库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Stasm(http://www.milbo.users.sonic.net/stasm/index.html)是一个C ++库,用于查找图像上的特征,应用主动形状模型的概念。

Stasm (http://www.milbo.users.sonic.net/stasm/index.html) is a C++ library for finding features on image, applying the concept of active shape models.

我试图使用AsasmSearchDll,它位于stasm DLL(stasm_dll),例如 this 。在C ++中,原型是

I am trying to use AsmSearchDll which is on stasm DLL (stasm_dll) like this on a C# project. In C++ the prototype is

void AsmSearchDll(
int *pnlandmarks, // out: number of landmarks, 0 if can't get landmarks
int landmarks[], // out: the landmarks, caller must allocate
const char image_name[], // in: used in internal error messages, if necessary
const char image_data[], // in: image data, 3 bytes per pixel if is_color
const int width, // in: the width of the image
const int height, // in: the height of the image
const int is_color, // in: 1 if RGB image, 0 if grayscale
const char conf_file0[], // in: 1st config filename, NULL for default
const char conf_file1[]); // in: 2nd config filename, NULL for default, "" for none

C#与此

[DllImport(@"..\data\stasm_dll.dll")]
public static extern void AsmSearchDll(
        out int pnlandmarks, // out: number of landmarks, 0 if can't get landmarks
        out int[] landmarks, // out: the landmarks, caller must allocate
        [MarshalAs(UnmanagedType.LPStr)]string imagename, // in: used in internal error messages, if necessary
        byte[] imagedata, // in: image data, 3 bytes per pixel if is_color
        int width, // in: the width of the image
        int height, // in: the height of the image
        int is_color, // in: 1 if RGB image, 0 if grayscale
        [MarshalAs(UnmanagedType.LPStr)]string conf_file0, // in: 1st config filename, NULL for default
        [MarshalAs(UnmanagedType.LPStr)]string conf_file1 // in: 2nd config filename, NULL for default, "" for none
    );

函数开始读取配置文件,但是它退出程序。我不知道发生了什么。任何建议?

The function starts to read the config files, but then it quits the program. I can't figure out what is going on. Any suggestions?

最好的祝福

推荐答案

在传递指向该函数的指针之前,首先要分配landmarks数组和一个int。

You have first to allocate the landmarks array and an int, before passing pointer to the function.

该函数在../data/中需要很多配置文件,请确保它存在。

The function need a lot of configuration file in ../data/, be sure it is there.

imagename字符串实际上应该是FILEPATH图片。没有开玩笑。它加载它并处理它。 Btw,imagingata必须指向分配的内存... ...

The imagename string should actually be the FILEPATH of the image. No kidding. It loads it and process it whatever. Btw, imagedata must point to allocated memory to...

这篇关于C#Interp。用于C ++中的活动形状模型库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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