Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring line: 832

basic_string(const _Elem *_Ptr) : _Mybase() { // construct from [_Ptr, <null>) _Tidy();

  assign(_Ptr);
    }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring line: 832

basic_string(const _Elem *_Ptr) : _Mybase() { // construct from [_Ptr, <null>) _Tidy();

  assign(_Ptr);
    }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

REDACTED:

Adding some code examples on how it was done.

  1. I made an array<string^&gt; to="" collect="" the="" data="" from="" boxes\editos="" on="" the="" form<="" li="">

array<string^, 1=""> ^cmd_args = gcnew array<string^&gt;(0); array="" for="" arguments,="" delegating="" memory="" int="" i="0;&lt;/p">

  1. Then I was adding elements to it with simple lines of code like this:

cmd_args->Resize<string ^&gt;(cmd_args,="" cmd_args-="">Length + 1); md_args[i++] = Application::StartupPath + "\Classifier\" + this->txtBoxName->Text->ToString() +".info";

  1. Then, when it took all the necessary info I converted it into single std::wstring

msclr::interop::marshal_context context;

for (int i = 0; i < cmd_args->Length; i++) // form the string { std::string standardString = context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

for (int j = 0; j < standardString.size(); j++)
{
    glob_tmp_char.push_back(standardString[j]);
}

}

  1. Senting the wstring to cmd_exec function

Exec_Cmd(glob_tmp_char);

(called in next function) LPWSTR ConvertToLPWSTR(const std::wstring& s) // converts my wstring to lpwstr { LPWSTR ws = new wchar_t[s.size() + 1]; copy(s.begin(), s.end(), ws); ws[s.size()] = 0; return ws; }

(actual execute funcion) void Exec_Cmd(std::wstring cmd) // std::string { /* Summary This script executes command line from the application Necessary to call two opencv cmd functions to build .vec file and then to build actual trained cascade.

this is going to be called from another function when 
will build cmd line param basing on user inputs.
*/

STARTUPINFO info = { sizeof(info) };
PROCESS_INFORMATION processInfo;
LPWSTR cmd_args = ConvertToLPWSTR(cmd);


if (CreateProcess(NULL, cmd_args, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &info,  &processInfo))
{
    WaitForSingleObject(processInfo.hProcess, INFINITE);
    CloseHandle(processInfo.hProcess);
    CloseHandle(processInfo.hThread);
}
else
{
    System::Windows::Forms::MessageBox::Show("The process could not be started...");
}

}

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring line: 832

basic_string(const _Elem *_Ptr) : _Mybase() { // construct from [_Ptr, <null>) _Tidy();

  assign(_Ptr);
    }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

REDACTED:

Adding some code examples on how it was done.

  1. I made an array<string^&gt; to="" collect="" the="" data="" from="" boxes\editos="" on="" the="" form<="" li="">

p="">

array<string^, 1=""> ^cmd_args = gcnew array<string^&gt;(0); array="" for="" arguments,="" delegating="" memory="" int="" i="0;&lt;/p">

    i="0;&lt;/p">

  1. Then I was adding elements to it with simple lines of code like this:

cmd_args->Resize<string ^&gt;(cmd_args,="" cmd_args-="">Length + 1); md_args[i++] = Application::StartupPath + "\Classifier\" + this->txtBoxName->Text->ToString() +".info";

  1. Then, when it took all the necessary info I converted it into single std::wstring

msclr::interop::marshal_context context;

for (int i = 0; i < cmd_args->Length; i++) // form the string { std::string standardString = context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

for (int j = 0; j < standardString.size(); j++)
{
    glob_tmp_char.push_back(standardString[j]);
}

}

  1. Senting the wstring to cmd_exec function

    Exec_Cmd(glob_tmp_char);

Exec_Cmd(glob_tmp_char);

(called in next function) function)

LPWSTR ConvertToLPWSTR(const std::wstring& s) // converts my wstring to lpwstr
{
    LPWSTR ws = new wchar_t[s.size() + 1];
    copy(s.begin(), s.end(), ws);
    ws[s.size()] = 0;
    return ws;
}

}

(actual execute funcion) funcion)

void Exec_Cmd(std::wstring cmd) // std::string
{
    /* Summary
    This script executes command line from the application
    Necessary to call two opencv cmd functions to build
    .vec file and then to build actual trained cascade.

cascade.

    this is going to be called from another function when 
 will build cmd line param basing on user inputs.
 */

 STARTUPINFO info = { sizeof(info) };
 PROCESS_INFORMATION processInfo;
 LPWSTR cmd_args = ConvertToLPWSTR(cmd);


 if (CreateProcess(NULL, cmd_args, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &info,  &processInfo))
 {
     WaitForSingleObject(processInfo.hProcess, INFINITE);
     CloseHandle(processInfo.hProcess);
     CloseHandle(processInfo.hThread);
 }
 else
 {
     System::Windows::Forms::MessageBox::Show("The process could not be started...");
    }
}

}

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring line: 832

basic_string(const _Elem *_Ptr) : _Mybase() { // construct from [_Ptr, <null>) _Tidy();

  assign(_Ptr);
    }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

REDACTED:

Adding some code examples on how it was done.

  1. I made an array<string^&gt; to="" collect="" the="" data="" from="" boxes\editos="" on="" the="" form<="" p="">

    array<string^, 1=""> li="">

array<String^, 1> ^cmd_args = gcnew array<string^&gt;(0); array="" for="" arguments,="" delegating="" memory="" int="" i="0;&lt;/p">

array<String^>(0); // Array for arguments, delegating memory int i = 0;
  1. Then I was adding elements to it with simple lines of code like this:

    cmd_args->Resize<string ^&gt;(cmd_args,="" cmd_args-="">Length

cmd_args->Resize<String ^>(cmd_args, cmd_args->Length + 1);
md_args[i++] = Application::StartupPath + "\Classifier\" "\\Classifier\\" + this->txtBoxName->Text->ToString() +".info";

+".info";
  1. Then, when it took all the necessary info I converted it into into single std::wstring

msclr::interop::marshal_context context;

context; for (int i = 0; i < cmd_args->Length; i++) // form the string { std::string standardString = context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

    for (int j = 0; j < standardString.size(); j++)
 {
     glob_tmp_char.push_back(standardString[j]);
    }
}

}

  1. Senting the wstring to cmd_exec function

    Exec_Cmd(glob_tmp_char);

Exec_Cmd(glob_tmp_char);

(called in next function)

LPWSTR ConvertToLPWSTR(const std::wstring& s) // converts my wstring to lpwstr
{
    LPWSTR ws = new wchar_t[s.size() + 1];
    copy(s.begin(), s.end(), ws);
    ws[s.size()] = 0;
    return ws;
}

(actual execute funcion)

void Exec_Cmd(std::wstring cmd) // std::string
{
    /* Summary
    This script executes command line from the application
    Necessary to call two opencv cmd functions to build
    .vec file and then to build actual trained cascade.

    this is going to be called from another function when 
    will build cmd line param basing on user inputs.
    */

    STARTUPINFO info = { sizeof(info) };
    PROCESS_INFORMATION processInfo;
    LPWSTR cmd_args = ConvertToLPWSTR(cmd);


    if (CreateProcess(NULL, cmd_args, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &info,  &processInfo))
    {
        WaitForSingleObject(processInfo.hProcess, INFINITE);
        CloseHandle(processInfo.hProcess);
        CloseHandle(processInfo.hThread);
    }
    else
    {
        System::Windows::Forms::MessageBox::Show("The process could not be started...");
    }
}
click to hide/show revision 5
No.5 Revision

updated 2016-06-21 04:57:04 -0600

berak gravatar image

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring
line: 832

832 basic_string(const _Elem *_Ptr) : _Mybase() { // construct from [_Ptr, <null>) _Tidy();

_Tidy();
>  assign(_Ptr);
  }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

REDACTED:

Adding some code examples on how it was done.

  1. I made an array<string^&gt; to="" collect="" the="" data="" from="" boxes\editos="" on="" the="" form<="" li=""> p="">

    array<string^, 1=""> ^cmd_args = gcnew array<string^&gt;(0); array="" for="" arguments,="" delegating="" memory="" int="" i="0;&lt;/p">

array<String^, 1> ^cmd_args = gcnew array<String^>(0); // Array for arguments, delegating memory
int i = 0;
  1. Then I was adding elements to it with simple lines of code like this:

cmd_args->Resize<String ^>(cmd_args, cmd_args->Length 

cmd_args->Resize<string ^&gt;(cmd_args,="" cmd_args-="">Length + 1); md_args[i++] = Application::StartupPath + "\\Classifier\\" "\Classifier\" + this->txtBoxName->Text->ToString() +".info";

    +".info";

  1. Then, when it took all the necessary info I converted it into into single std::wstring

msclr::interop::marshal_context context; context;

for (int i = 0; i < cmd_args->Length; i++) // form the string { std::string standardString = context.marshal_as<std::string>(ptr_cmd_args[i]->ToString()); context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

for (int j = 0; j < standardString.size(); j++)
 {
     glob_tmp_char.push_back(standardString[j]);
    }
}

    }

  1. Senting the wstring to cmd_exec function

Exec_Cmd(glob_tmp_char);

Exec_Cmd(glob_tmp_char);

(called in next function)

LPWSTR ConvertToLPWSTR(const std::wstring& s) // converts my wstring to lpwstr
{
    LPWSTR ws = new wchar_t[s.size() + 1];
    copy(s.begin(), s.end(), ws);
    ws[s.size()] = 0;
    return ws;
}

(actual execute funcion)

void Exec_Cmd(std::wstring cmd) // std::string
{
    /* Summary
    This script executes command line from the application
    Necessary to call two opencv cmd functions to build
    .vec file and then to build actual trained cascade.

    this is going to be called from another function when 
    will build cmd line param basing on user inputs.
    */

    STARTUPINFO info = { sizeof(info) };
    PROCESS_INFORMATION processInfo;
    LPWSTR cmd_args = ConvertToLPWSTR(cmd);


    if (CreateProcess(NULL, cmd_args, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &info,  &processInfo))
    {
        WaitForSingleObject(processInfo.hProcess, INFINITE);
        CloseHandle(processInfo.hProcess);
        CloseHandle(processInfo.hThread);
    }
    else
    {
        System::Windows::Forms::MessageBox::Show("The process could not be started...");
    }
}

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring
line: 832

basic_string(const _Elem *_Ptr)
        : _Mybase()
        {   // construct from [_Ptr, <null>)
        _Tidy();
>       assign(_Ptr);
        }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

REDACTED:

Adding some code examples on how it was done.

  1. I made an array<string^&gt; to="" collect="" the="" data="" from="" boxes\editos="" on="" the="" form<="" p="">

    array<string^, 1=""> ^cmd_args = gcnew array<string^&gt;(0); array="" for="" arguments,="" delegating="" memory="" int="" i="0;&lt;/p">

  2. Then I was adding elements to it with simple lines of code like this:

    cmd_args->Resize<string ^&gt;(cmd_args,="" cmd_args-="">Length + 1); md_args[i++] = Application::StartupPath + "\Classifier\" + this->txtBoxName->Text->ToString() +".info";

  3. Then, when it took all the necessary info I converted it into single std::wstring

    msclr::interop::marshal_context context;

    for (int i = 0; i < cmd_args->Length; i++) // form the string { std::string standardString = context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

    for (int j = 0; j < standardString.size(); j++)
    {
        glob_tmp_char.push_back(standardString[j]);
    }
    

    }

  4. Senting the wstring to cmd_exec function

Exec_Cmd(glob_tmp_char);

(called in next function)

LPWSTR ConvertToLPWSTR(const std::wstring& s) // converts my wstring to lpwstr
{
    LPWSTR ws = new wchar_t[s.size() + 1];
    copy(s.begin(), s.end(), ws);
    ws[s.size()] = 0;
    return ws;
}

(actual execute funcion)

void Exec_Cmd(std::wstring cmd) // std::string
{
    /* Summary
    This script executes command line from the application
    Necessary to call two opencv cmd functions to build
    .vec file and then to build actual trained cascade.

    this is going to be called from another function when 
    will build cmd line param basing on user inputs.
    */

    STARTUPINFO info = { sizeof(info) };
    PROCESS_INFORMATION processInfo;
    LPWSTR cmd_args = ConvertToLPWSTR(cmd);


    if (CreateProcess(NULL, cmd_args, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &info,  &processInfo))
    {
        WaitForSingleObject(processInfo.hProcess, INFINITE);
        CloseHandle(processInfo.hProcess);
        CloseHandle(processInfo.hThread);
    }
    else
    {
        System::Windows::Forms::MessageBox::Show("The process could not be started...");
    }
}

As I said it works well when it about making .vec file, but crashes on attempt to do the same on traincascade

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring
line: 832

basic_string(const _Elem *_Ptr)
        : _Mybase()
        {   // construct from [_Ptr, <null>)
        _Tidy();
>       assign(_Ptr);
        }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

REDACTED:

Adding some code examples on how it was done.

  1. I made an array<string^&gt; to="" collect="" the="" data="" from="" boxes\editos="" on="" the="" form<="" p="">

    array<string^, 1=""> li="">

array<String^, 1> ^cmd_args = gcnew array<string^&gt;(0); array="" for="" arguments,="" delegating="" memory="" int="" i="0;&lt;/p">

array<String^>(0); // Array for arguments, delegating memory int i = 0;
  1. Then I was adding elements to it with simple lines of code like this:

    cmd_args->Resize<string ^&gt;(cmd_args,="" cmd_args-="">Length

cmd_args->Resize<String ^>(cmd_args, cmd_args->Length + 1);
md_args[i++] = Application::StartupPath + "\Classifier\" "\\Classifier\\" + this->txtBoxName->Text->ToString() +".info";

+".info";
  1. Then, when it took all the necessary info I converted it into into single std::wstring

msclr::interop::marshal_context context;

context; for (int i = 0; i < cmd_args->Length; i++) // form the string { std::string standardString = context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

    for (int j = 0; j < standardString.size(); j++)
 {
     glob_tmp_char.push_back(standardString[j]);
    }
}

}

  1. Senting the wstring to cmd_exec function

Exec_Cmd(glob_tmp_char);

Exec_Cmd(glob_tmp_char);

(called in next function)

LPWSTR ConvertToLPWSTR(const std::wstring& s) // converts my wstring to lpwstr
{
    LPWSTR ws = new wchar_t[s.size() + 1];
    copy(s.begin(), s.end(), ws);
    ws[s.size()] = 0;
    return ws;
}

(actual execute funcion)

void Exec_Cmd(std::wstring cmd) // std::string
{
    /* Summary
    This script executes command line from the application
    Necessary to call two opencv cmd functions to build
    .vec file and then to build actual trained cascade.

    this is going to be called from another function when 
    will build cmd line param basing on user inputs.
    */

    STARTUPINFO info = { sizeof(info) };
    PROCESS_INFORMATION processInfo;
    LPWSTR cmd_args = ConvertToLPWSTR(cmd);


    if (CreateProcess(NULL, cmd_args, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &info,  &processInfo))
    {
        WaitForSingleObject(processInfo.hProcess, INFINITE);
        CloseHandle(processInfo.hProcess);
        CloseHandle(processInfo.hThread);
    }
    else
    {
        System::Windows::Forms::MessageBox::Show("The process could not be started...");
    }
}

As I said it works well when it about making .vec file, but crashes on attempt to do the same on traincascade

Having problem with opencv_traincascade.exe crashing /w exception

Good day,

I've got some project in University running wild with this problem. What I'm trying to do is to get these console-called functions like opencv_createsamples and opencv_traincascade executing from my app where user can just specify some info in Windows Form app. I made it through with opencv_createsamples which makes me a good .vec file from specified folders with negs and pos but when it comes to opencv_traincascade it just crashes. On debug I've got this:

xstring
line: 832

basic_string(const _Elem *_Ptr)
        : _Mybase()
        {   // construct from [_Ptr, <null>)
        _Tidy();
>       assign(_Ptr);
        }

The thread 0x3230 has exited with code 0 (0x0). Unhandled exception thrown: read access violation. _Ptr was nullptr.

What can actually be wrong with this stuff? Many thanks in advance!

REDACTED:

Adding some code examples on how it was done.

  1. I made an array<string^&gt; to="" collect="" the="" data="" from="" boxes\editos="" on="" the="" form<="" li="">
array<String^, 1> ^cmd_args = gcnew array<String^>(0); // Array for arguments, delegating memory
int i = 0;
  1. Then I was adding elements to it with simple lines of code like this:
cmd_args->Resize<String ^>(cmd_args, cmd_args->Length + 1);
md_args[i++] = Application::StartupPath + "\\Classifier\\" + this->txtBoxName->Text->ToString() +".info";
  1. Then, when it took all the necessary info I converted it into single std::wstring
msclr::interop::marshal_context context;

for (int i = 0; i < cmd_args->Length; i++) // form the string
{
    std::string standardString = context.marshal_as<std::string>(ptr_cmd_args[i]->ToString());

    for (int j = 0; j < standardString.size(); j++)
    {
        glob_tmp_char.push_back(standardString[j]);
    }
}
  1. Senting the wstring to cmd_exec function
Exec_Cmd(glob_tmp_char);

(called in next function)

LPWSTR ConvertToLPWSTR(const std::wstring& s) // converts my wstring to lpwstr
{
    LPWSTR ws = new wchar_t[s.size() + 1];
    copy(s.begin(), s.end(), ws);
    ws[s.size()] = 0;
    return ws;
}

(actual execute funcion)

void Exec_Cmd(std::wstring cmd) // std::string
{
    /* Summary
    This script executes command line from the application
    Necessary to call two opencv cmd functions to build
    .vec file and then to build actual trained cascade.

    this is going to be called from another function when 
    will build cmd line param basing on user inputs.
    */

    STARTUPINFO info = { sizeof(info) };
    PROCESS_INFORMATION processInfo;
    LPWSTR cmd_args = ConvertToLPWSTR(cmd);


    if (CreateProcess(NULL, cmd_args, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &info,  &processInfo))
    {
        WaitForSingleObject(processInfo.hProcess, INFINITE);
        CloseHandle(processInfo.hProcess);
        CloseHandle(processInfo.hThread);
    }
    else
    {
        System::Windows::Forms::MessageBox::Show("The process could not be started...");
    }
}

As I said it works well when it about making .vec file, but crashes on attempt to do the same on traincascade