Ask Your Question

Revision history [back]

To solve your problem, please first follow peoples guidance in your other topics and use the C++ interface!

For windows, the forms indeed use a terrible format, in a specified protected string format, but translating them to a Mat element container (which is used in C++ - api of openCV) can be done straightforward by this approach.

String^ temp_input = textbox_you_want_to_retrieve->Text;    
IntPtr pointer_to_text_string = Marshal::StringToHGlobalAnsi(temp_input);   
const char* string_for_opencv = static_cast<const char*>(pointer_to_text_string.ToPointer());
Mat image = imread(string_for_opencv);

This code will need you to do one more thing, to be able to use the marshalling functionality and that is to add the following on top of your header:

using namespace System::Runtime::InteropServices;

Or you can just print that complete command in front of the marchalling operations.