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
 Face Detection C++
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

gajendra

16 Posts

Posted - Mar 10 2012 :  08:09:49  Show Profile  Reply
Hi, do you have coding for c++ for this delphi code :

var
objectsFinder:TIEVisionObjectsFinder;
rects:TIEVisionVectorRect;
...
// load two face detectors
objectsFinder := IEVisionLib.createObjectsFinder();
objectsFinder.addClassifier('face detector 1', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT_TREE));
objectsFinder.addClassifier('face detector 2', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_DEFAULT));

// detect objects
objectsFinder.findIn(ImageEnView1.IEBitmap.GetIEVisionImage());

// merge intersecting rectangles of all searched objects
rects := objectsFinder.mergeAllRects();

// loop among rectangles
for i:=0 to rects.size-1 do
begin
ImageEnView1.ObjPenWidth[-1] := 2;
with rects.getRect(i) do
begin
... do something with the rectangle coordinates and size
end;
end;

Thanks

fab

1310 Posts

Posted - Mar 10 2012 :  10:35:35  Show Profile  Reply
Hi,
some conversion rules:
- each interface is embedded inside a C++ template with "_di_" prefix. So, for example, TIEVisionObjectFind becomes _di_TIEVisionObjectFinder
- each method returns an HRESULT, so the actual return value is the last parameter
- the second-last parameter is always "false". This is an internal parameter.
- when a method expects a parent interface (like addClassifier that wants a TIEVisionBase, but we have a TIEVisionCascadeClassifier ), perform a cast, better a static_cast to avoid programming errors

Here is an example of conversion:

	// check if "ievision.dll" is available
	if (!IEVisionAvailable())
	{
		ShowMessage("ievision.dll not loaded!");
		exit;
	}

	// load two face detectors
	_di_TIEVisionObjectsFinder objectsFinder;
	IEVisionLib->createObjectsFinder(false, objectsFinder);

	_di_TIEVisionCascadeClassifier faceDetector1, faceDetector2;
	IEVisionLib->createCascadeClassifier(":FRONTALFACEALTTREE", false, faceDetector1);
	IEVisionLib->createCascadeClassifier(":FRONTALFACEDEFAULT", false, faceDetector2);
	objectsFinder->addClassifier("face detector 1", static_cast<TIEVisionBase *>(faceDetector1));
	objectsFinder->addClassifier("face detector 2", static_cast<TIEVisionBase *>(faceDetector2));

	// detect objects
	objectsFinder->findIn(ImageEnView1->IEBitmap->GetIEVisionImage());

	// merge intersecting rectangles of all searched objects
	_di_TIEVisionVectorRect rects;
	objectsFinder->mergeAllRects(false, rects);

	// loop among rectangles
	int rectCount;
	rects->size(false, rectCount);
	for (int i=0; i != rectCount; ++i)
	{
		TIEVisionRect rectangle;
		rects->getRect(i, false, rectangle);
		// ... do something with the rectangle coordinates and size
		ImageEnView1->IEBitmap->Canvas->Pen->Color = clRed;
		ImageEnView1->IEBitmap->Canvas->Brush->Style = bsClear;
		ImageEnView1->IEBitmap->Canvas->Rectangle(rectangle.x, rectangle.y, rectangle.x+rectangle.width, rectangle.y+rectangle.height);
	}
Go to Top of Page

gajendra

16 Posts

Posted - Mar 10 2012 :  11:20:14  Show Profile  Reply
Thank you very much, great help.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: