Go to Post Waiting for the kick off is like studing the molecular structure of grass while being hit on the head by a frying pan - infinitydex [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-02-2012, 16:42
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Vision Tracking imaqMorphology exception

Hi, we have been having trouble getting vision tracking, and our problem is at the step in which when we are taking away small objects.

Here's our code:
Code:
AxisCamera& camera = AxisCamera::GetInstance("10.13.34.11");
	if (camera.IsFreshImage())
	{
		int low = 125;
		int high = 255;
		StructuringElement* sElement;
		sElement->matrixCols = 3;
		sElement->matrixRows = 3;
		sElement->hexa = FALSE;
		HSLImage* image = camera.GetImage();
		MonoImage* luminance = image->GetLuminancePlane();
		image->ReplaceRedPlane(luminance);
		image->ReplaceGreenPlane(luminance);
		image->ReplaceBluePlane(luminance);
		BinaryImage* bImage = image->ThresholdHSL(low, high, low, high, low, high);
		BinaryImage* bImage1 = new BinaryImage();
		imaqMorphology(bImage1 -> GetImaqImage(), bImage -> GetImaqImage(), IMAQ_ERODE, sElement);
		delete bImage;
		BinaryImage* bImage2 = new BinaryImage();
		imaqMorphology(bImage2 -> GetImaqImage(), bImage1 -> GetImaqImage(), IMAQ_ERODE, sElement);
		delete bImage1;
		BinaryImage* bImage3 = new BinaryImage();
		imaqMorphology(bImage3 -> GetImaqImage(), bImage2 -> GetImaqImage(), IMAQ_ERODE, sElement);
		delete bImage2;
		BinaryImage* bImage4 = new BinaryImage();
		imaqMorphology(bImage4 -> GetImaqImage(), bImage3 -> GetImaqImage(), IMAQ_ERODE, sElement);
		delete bImage3;
		BinaryImage* bImage5 = new BinaryImage();
		imaqMorphology(bImage5 -> GetImaqImage(), bImage4 -> GetImaqImage(), IMAQ_DILATE, sElement);
		delete bImage4;
		BinaryImage* bImage6 = new BinaryImage();
		imaqMorphology(bImage6 -> GetImaqImage(), bImage5 -> GetImaqImage(), IMAQ_DILATE, sElement);
		delete bImage5;
		BinaryImage* bImage7 = new BinaryImage();
		imaqMorphology(bImage7 -> GetImaqImage(), bImage6 -> GetImaqImage(), IMAQ_DILATE, sElement);
		delete bImage6;
		BinaryImage* bImage8 = new BinaryImage();
	    imaqMorphology(bImage8 -> GetImaqImage(), bImage7 -> GetImaqImage(), IMAQ_DILATE, sElement);
	    delete bImage7;
		vector<ParticleAnalysisReport>* particles = bImage -> GetOrderedParticleAnalysisReports();
		cout << particles->size() << endl;
		delete particles;
		delete bImage8;
		delete luminance;
		delete image;
	}
Our problem is at the imaqMorphology functions. It looks weird because this is our most recent try at fixing it. The code compiles successfully, but gives this error in the console, and prevents the robot from running.


0x2a8cda8 (FRC_RobotTask): memPartAlloc: block too big 3913540616 bytes (0x8 alig
in partition 0x34f600
0
Default TeleopContinuous() method... Overload me!
0x2a8cda8 (FRC_RobotTask): memPartAlloc: block too big 3368229384 bytes (0x8 alig
in partition 0x34f600

program
Exception current instruction address: 0x00000000
Machine Status Register: 0x0008b012
Condition Register: 0x28000828
Task: 0x2a8cda8 "FRC_RobotTask"
0x2a8cda8 (FRC_RobotTask): task 0x2a8cda8 has had a failure and has been stopped.
0x2a8cda8 (FRC_RobotTask): fatal kernel task-level exception!


The first block of the error sometimes repeats itself over and over again.

We have looked at the java version for vision tracking, but it doesn't really help us as some of the functions in java aren't in c++.

Thank you very much.
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2012, 14:48
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Re: Vision Tracking imaqMorphology exception

The ImaqMorphology function's first two parameters are pointers to Image objects. The first Image is the destination image, and the second is the source image. The function morphs the second image and puts the changed image for the first parameter. I think the problem we have is that we do not actually pass in the object itself, and instead, passes in a temporary object. We have tried creating Image objects so that we pass in the object itself, but when we tried to define an Image object, it gives an error saying that it's an incomplete type.
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2012, 16:42
Navi Navi is offline
Registered User
AKA: Ivan
FRC #0840 (Aragon Robotics Team)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2009
Location: San Mateo
Posts: 12
Navi is an unknown quantity at this point
Re: Vision Tracking imaqMorphology exception

That looks like the problem. To create an image, you need to use the imaq or frc function. Try this instead:

Code:
Image* processedImage = imaqCreateImage(IMAQ_IMAGE_U8, 3);
imaqMorphology(processedImage, bImage -> GetImaqImage(), IMAQ_ERODE, sElement);
When you wish to dispose of the image, you can then use
Code:
imaqDispose(processedImage);
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2012, 17:02
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Re: Vision Tracking imaqMorphology exception

It fixed the problem. Thank you.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:40.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi