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
 Questions about using TrackObject
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

tylin123

Taiwan
25 Posts

Posted - May 09 2018 :  03:22:50  Show Profile  Reply
Dear sir,

I am a user of c++ builder (under CB 10.1 + ImageEn 7.5 + IEVision 4.0)

I use the TrackObjects sample from IEVision demos, and after translate delphi to the C++ syntax.
After compiling and linking, it looks like everything is normal, but after the execution, the tracked object is opposite to the rectangular area.
(When the object being tracked goes up, the red rectangle goes down)

I listed some of the code below. Where is the problem?

P.S:
I'm not familiar with Delpi, but the example is only delphi, so please tell me where is a bug in the program.

Thank You .

James Lin.


                                :
                                :                                        
oImageEnView->IO->DShowParams->GetSample(oImageEnView->->IEBitmap);
// ------------------------------------------------------------
// localize object (use CamShift)
Robj_IEBitmap_BKPROJ->GetIEVisionImage()->flip(ievY_AXIS, obj_IEVisionImage);
// --------------------------------------------
ObjTracker->locateNewPosition(obj_IEVisionImage, obj_IEVisionImageBKPROJ,
                              stru_rotRect);
// ------------------------------------------------------------
// localized?
if((stru_rotRect.size.width > 0)  &&
   (stru_rotRect.size.height > 0) &&
    obj_IEVisionImageBKPROJ!= NULL )
{
    // display back projected image (just for testing)
    obj_IEVisionImage->getScanline(0, mvp_SRCBUFF);
    // --------------------------------------------
    obj_IEVisionImage->getWidth(mi_Width);
    obj_IEVisionImage->getHeight(mi_Height);
    obj_IEVisionImage->getRowLen(mi_RowLen);
    // --------------------------------------------
    // show rect
    IECanvas->Translate(stru_rotRect.center.x,
                                    stru_rotRect.center.y);
    IECanvas->Rotate(stru_rotRect.angle);
    // --------------------------------------------
    // show rect
    IECanvas->Pen->Color = clRed;
    IECanvas->Pen->Width = 3;
    IECanvas->Brush->Style = bsClear;
    IECanvas->Rectangle(-1 * stru_rotRect.size.width  / 2,
                        -1 * stru_rotRect.size.height / 2,
                             stru_rotRect.size.width  / 2,
                             stru_rotRect.size.height / 2);
                                :
                                :                                    

xequte

39142 Posts

Posted - May 09 2018 :  15:40:56  Show Profile  Reply
Hi

Please try removing the "flip".

Change this:

// localize object (use CamShift)
Robj_IEBitmap_BKPROJ->GetIEVisionImage()->flip(ievY_AXIS, obj_IEVisionImage);
// --------------------------------------------
ObjTracker->locateNewPosition(obj_IEVisionImage, obj_IEVisionImageBKPROJ,
                              stru_rotRect);


To:

// localize object (use CamShift)
ObjTracker->locateNewPosition(Robj_IEBitmap_BKPROJ->GetIEVisionImage(), obj_IEVisionImageBKPROJ,
                              stru_rotRect);



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

tylin123

Taiwan
25 Posts

Posted - May 10 2018 :  03:28:51  Show Profile  Reply
Hi, Nigel:

Thanks for your reply.

Unfortunately, after modifying the code based on your suggestions, the problem is still not resolved.
When I after removing the flip(ievY_AXIS,...) in the code, the image Left and right directions will be reversed. However, the Vertical direction of the red box and the object is still in the opposite direction.

The result of the test is in the following video.
Video URL >> http://mis.gotech.biz/file/video/20180510_150034.mp4

Is there any other suggestion?

Thank you.

James Lin
Go to Top of Page

xequte

39142 Posts

Posted - May 10 2018 :  21:06:28  Show Profile  Reply
Hi James

That's weird, what if you use one of the other flips: ievX_AXIS or ievXY_AXISES?

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

tylin123

Taiwan
25 Posts

Posted - May 11 2018 :  00:44:01  Show Profile  Reply
Hi Nigel,

Yes. I tried all three methods, but the problem is the same.

Because I'm not familiar with Delphi, so I would like to ask whether the following code syntax is equivalent? (Delphi v.s C++)
Is it possible that this part of the code caused problems?

p.s:
I have a suggestion.
Will there be more C++ example programs in future releases?


James Lin.

Delphi Code:

    RECT.Left   = -trunc(rotRect.size.width/2);
    RECT.Top    = -trunc(rotRect.size.height/2);
    RECT.Right  = trunc(rotRect.size.width/2);
    RECT.Bottom = trunc(rotRect.size.height/2);

C++ Builder Code:

    RECT->Left   = -1*((int)(rotRect.size.width  / 2.0));
    RECT->Top    = -1*((int)(rotRect.size.height / 2.0));
    RECT->Right  =     (int)(rotRect.size.width  / 2.0);
    RECT->Bottom =     (int)(rotRect.size.height / 2.0);
Go to Top of Page

xequte

39142 Posts

Posted - May 11 2018 :  22:43:33  Show Profile  Reply
Hi James

Yes, your code above should be identical. Can you email your test project to us so we can try it here.



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

tylin123

Taiwan
25 Posts

Posted - May 12 2018 :  02:16:09  Show Profile  Reply
Dear Nigel,

I have sent the download URL of the code to your mail.
Thank you very much for your patience.

James Lin.
Go to Top of Page

xequte

39142 Posts

Posted - May 14 2018 :  17:47:00  Show Profile  Reply
I have attached a C++Builder version of our demo for Object Tracking:

attach/xequte/2018514174653_TrackObjects_CPP.zip
61.33 KB

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

tylin123

Taiwan
25 Posts

Posted - May 15 2018 :  21:50:48  Show Profile  Reply
Hi Nigel,

Thank you very much for your code to help me solve the problem.

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