ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 About the use function of matchTemplate() (CB++)
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

tylin123

Taiwan
25 Posts

Posted - Mar 08 2018 :  07:11:43  Show Profile  Reply
Dear sir:

In the process of using matchTemplate() function will be occur the following error message:



The IEVision is version 4.0.0.

At the same time, I also determine that ievision.dll already exists in the directory.

I've sent the complete project code to your mail account 'xequte'.


So please help me confirm whether the program is using the wrong way.

P.S: In CB++ version, the matchTemplate() description in help is not the same as the actual use.

Thank you.

James Lin (tylin123)

xequte

39053 Posts

Posted - Mar 12 2018 :  00:38:21  Show Profile  Reply
Hi James

We'll get back to your shortly...

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

tylin123

Taiwan
25 Posts

Posted - Mar 16 2018 :  02:11:47  Show Profile  Reply
Hi Nigel:

Is there any progress on the issues mentioned above?

Waiting for good news.

James Lin
Go to Top of Page

xequte

39053 Posts

Posted - Mar 19 2018 :  16:39:12  Show Profile  Reply
Hi James,

I'm afraid we have not been able to look into this yet.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

tylin123

Taiwan
25 Posts

Posted - Mar 21 2018 :  02:05:34  Show Profile  Reply
Dear Nigel:

I re-post the code and download URL listed below.

An error occurs while executing at function of ..:

obj_Image->matchTemplate(obj_templ, mE_IEVTMM, stru_IEV_RECT);


This is the URL of the code:
http://mis.gotech.biz/file/doc/PATTERN.zip

Thank you.

James Lin.


#include <vcl.h>
#pragma hdrstop

#include "Main_Form.h"
// ----------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "hyiedefs"
#pragma link "hyieutils"
#pragma link "iemview"
#pragma link "iesettings"
#pragma link "ievect"
#pragma link "ieview"
#pragma link "iexBitmaps"
#pragma link "iexLayers"
#pragma link "iexRulers"
#pragma link "imageenview"
#pragma resource "*.dfm"
TMainForm *MainForm;
// ----------------------------------------------------------------------------

__fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner)
{
    this->CUmus_IEVisionDLLPath = TMainForm::CUF_FindIEVisionDLLPath();

    TMainForm::CUF_INIT_IEVision();
    // ------------------------------------------------------------
    // (1) Init.
    TMainForm::CVF_InitComponent();
    // ------------------------------------------------------------
}

// ============================================================================
//                                P R I V A T E
// ============================================================================
void TMainForm::CVF_InitComponent(void)
{
}

UnicodeString TMainForm::CUF_FindIEVisionDLLPath(void)
{
    UnicodeString mus_sExePath,
                  musa_Result[5],
                  mus_Result;
    int           mi_c;

    mus_sExePath = ::IncludeTrailingBackslash(ExtractFilePath(Application->ExeName));
    // ------------------------------------------------------------
    mus_Result   = "";
    // ------------------------------------------------------------
    // In same folder as EXE?
    musa_Result[0] = mus_sExePath+ IEVISION_32BIT_DLL_FILENAME1;
    // In Registered version folder?
    musa_Result[1] = mus_sExePath+ "..\\..\\..\\Trial\\" + IEVISION_32BIT_DLL_FILENAME1;
    // In trial version folder?
    musa_Result[2] = mus_sExePath+ "..\\..\\..\\Registered\\" + IEVISION_32BIT_DLL_FILENAME1;
    // In parent folder of EXE?
    musa_Result[3] = mus_sExePath+ "..\\" + IEVISION_32BIT_DLL_FILENAME1;
    // Or its parent?
    musa_Result[4] = mus_sExePath+ "..\\..\\" + IEVISION_32BIT_DLL_FILENAME1;
    // ------------------------------------------------------------
    for(mi_c = 0; mi_c < 5; mi_c++)
    {
        // --------------------------------------------
        if(::FileExists(musa_Result[mi_c]))
        {
            mus_Result = musa_Result[mi_c];
            // --------------------------------------------
            break;
        }
    }
    // ------------------------------------------------------------
    return(mus_Result);
}

bool TMainForm::CUF_INIT_IEVision(void)
{
    bool mB_RetVal;

    mB_RetVal = false;
    // ------------------------------------------------------------
    if(!this->CUmus_IEVisionDLLPath.IsEmpty())
    {
        // Initialize DLL in custom location
	    ::IEInitialize_ievision(WideString(this->CUmus_IEVisionDLLPath), false);
        // --------------------------------------------
        mB_RetVal = ::IEVisionAvailable();
    }
    // ------------------------------------------------------------
    return(mB_RetVal);
}

void __fastcall TMainForm::FormCreate(TObject *Sender)
{
    UnicodeString mus_ExePath;

    ImageEnMView1->SoftShadow->Enabled = true;
    // ------------------------------------------------------------
    mus_ExePath = ::IncludeTrailingBackslash(ExtractFilePath(Application->ExeName));
    // ------------------------------------------------------------
    ImageEnVect1->IO->LoadFromFile(mus_ExePath + "\\coins.jpg");
    // ------------------------------------------------------------
    ImageEnMView1->MIO->LoadFromFile(mus_ExePath + "\\1.png");
    ImageEnMView1->MIO->LoadFromFile(mus_ExePath + "\\2.png");
    ImageEnMView1->MIO->LoadFromFile(mus_ExePath + "\\3.png");
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Button1Click(TObject *Sender)
{
  ImageEnVect1->IO->LoadFromFile(ImageEnVect1->IO->ExecuteOpenDialog());
  ImageEnVect1->RemoveAllObjects();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Button3Click(TObject *Sender)
{
  ImageEnMView1->MIO->LoadFromFile(ImageEnMView1->MIO->ExecuteOpenDialog());
  ImageEnVect1->RemoveAllObjects();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Button4Click(TObject *Sender)
{
  ImageEnVect1->ClearAll();
  ImageEnMView1->Clear();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Button5Click(TObject *Sender)
{
    TIEVisionImage               *obj_Image,
                                 *obj_templ;
    TIEVisionRect                stru_IEV_RECT;
    TIEVisionTemplateMatchMethod mE_IEVTMM;
    int                          mi_c;

    ImageEnVect1->RemoveAllObjects();
    // ------------------------------------------------------------
    // for each image in TImageEnMView (template images)
    for(mi_c = 0; mi_c < ImageEnMView1->ImageCount; mi_c++)
    {
        // get image where to search in
        obj_Image = ImageEnVect1->IEBitmap->GetIEVisionImage();
        // --------------------------------------------
        // get the template image to search
        obj_templ = ImageEnMView1->GetTIEBitmap(mi_c)->GetIEVisionImage();
        // --------------------------------------------
        mE_IEVTMM = (TIEVisionTemplateMatchMethod)ComboBox1->ItemIndex;
        // --------------------------------------------
        // perform template searching
        obj_Image->matchTemplate(obj_templ, mE_IEVTMM, stru_IEV_RECT);
        // --------------------------------------------
        // draw a red box around the found rectangle
        ImageEnVect1->ObjPenWidth[-1] = 3;
        ImageEnVect1->AddNewObject(iekBOX,
                                   IEVisionRectToTRect(stru_IEV_RECT), clRed);
        // --------------------------------------------
        ImageEnMView1->ReleaseBitmap(mi_c);
    }
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::ComboBox1Change(TObject *Sender)
{
    TMainForm::Button5Click(Sender);
}
//---------------------------------------------------------------------------

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: