Go to Post You can be extra safe or you can be competative - its your choice. - Raul [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 25-01-2017, 10:43
GRSICP GRSICP is offline
Greta Rauch
FRC #5822 (WolfByte)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2010
Location: Chicago
Posts: 26
GRSICP is an unknown quantity at this point
GRIP and Java Code Not Agreeing

I'm new to vision processing and I've run into a problem. I currently have my Java code set up to process the reflective tape from the gear pegs using OpenCV. When I run this code, often only one of the two vision targets is identified. I saved the images that were failing and then fed them through GRIP. GRIP consistently finds both targets.

Here is a picture of my GRIP program with one of the failed images: http://imgur.com/iGsEQeK

Here is the processing part of the code I am running in Java:
Code:
Imgproc.cvtColor(bgr, hsvConvert, Imgproc.COLOR_BGR2HSV); 
			Core.inRange(hsvConvert, new Scalar (0, 0, 0), new Scalar (180, 255, 64), hsv); //those two Scalar values are the the max and min HSV values respectively. Those were determined in GRIP. 
			Imgproc.findContours(hsv, contours, mhierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); //first enum lets you control things about hierarchy, I chose option with no hierarchy 
			Imgproc.drawContours(bgr, contours,0,new Scalar (0,255,0),1); 
			int idex=0; 
			int size = contours.size();
			
			for (idex=0; idex < contours.size(); idex++)
			{
				test = contours.get(idex); 
				nums = findCenterXYDistance(test.toList());
				System.out.println("MaxX: " +nums[0]+ "; Width: " + nums[1] + "; MaxY: " + nums[2] + "; Height: " + nums[3]); 
				targetRatio = nums[3]/nums[1];
				System.out.println("Ratio: " + targetRatio + "; Area: " + Imgproc.contourArea(test)); 
				
				if (Imgproc.contourArea(test)>100)
				{
					finalContours.add(test); 
				}
				idex++; 
			}
As far as I can tell, GRIP and my code should produce the same results. Any ideas on why my output would be different?
Reply With Quote
  #2   Spotlight this post!  
Unread 25-01-2017, 10:50
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 136
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: GRIP and Java Code Not Agreeing

You're doing idex++ twice.

And why are you copying the GRIP pipeline by hand? GRIP can generate code right into your program so you don't have to.

Generating code
Using it in a robot program
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #3   Spotlight this post!  
Unread 25-01-2017, 11:01
GRSICP GRSICP is offline
Greta Rauch
FRC #5822 (WolfByte)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2010
Location: Chicago
Posts: 26
GRSICP is an unknown quantity at this point
Re: GRIP and Java Code Not Agreeing

Good catch! Hopefully that's the problem, I'll retest the code this afternoon.

I should have explained more completely, I am running this code on a raspberry pi so I didn't want to use GRIP.
Reply With Quote
  #4   Spotlight this post!  
Unread 25-01-2017, 11:13
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 136
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: GRIP and Java Code Not Agreeing

You can still use GRIP to generate code to use in a raspberry pi program.
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #5   Spotlight this post!  
Unread 25-01-2017, 12:48
GRSICP GRSICP is offline
Greta Rauch
FRC #5822 (WolfByte)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2010
Location: Chicago
Posts: 26
GRSICP is an unknown quantity at this point
Re: GRIP and Java Code Not Agreeing

When I first looked into vision processing over Christmas break, I was originally hoping to use GRIP. However, when I looked at the then-current version of GRIP's instructions for install, it did not seem to be supported for the Raspberry pi. Therefore, I went ahead and learned to use OpenCV. I have not looked at more recent versions of GRIP, so this might have changed. Or I may have misunderstood originally.
Reply With Quote
  #6   Spotlight this post!  
Unread 25-01-2017, 13:34
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 136
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: GRIP and Java Code Not Agreeing

GRIP doesn't officially support the pi. Java doesn't have the UI libraries for the pi, but there was a community effort to get it running in headless mode with the deploy functionality. But we've added code generation since then to replace it.
__________________
WPILib
GRIP, RobotBuilder
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 13:15.

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