I am using Dlib - Face_detection_landmark.cpp in my c++ project.
my .cpp code as below :
__declspec(dllexport) char* FaceDetection( const wchar_t* filename)
{
std::wstring ws(filename);
String path(ws.begin(), ws.end());
array2d<unsigned char> img;
load_image(img, path);
pyramid_up(img);
frontal_face_detector detector = get_frontal_face_detector();
// Now tell the face detector to give us a list of bounding boxes
// around all the faces it can find in the image.
std::vector<dlib::rectangle> dets = detector(img);
std::string imageRect = "" + std::to_string(dets[0].left()) +
std::to_string(dets[0].left());
char* pchr = (char*)imageRect.c_str();
return pchr;
}
}
And my c# code is :
[DllImport("FaceDetector.dll",
CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Unicode)]
static extern string FaceDetection(string filename);
void main()
{
string filename = "some path";
string s = "";
s = FaceDetection(filename);
}
Error : value of string s is null.
Anyone can help on this?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…