View Single Post
  #1   Spotlight this post!  
Unread 02-26-2016, 01:53 PM
jabarabara's Avatar
jabarabara jabarabara is offline
Registered User
FRC #2415 (WiredCats)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2012
Location: Atlanta, Georgia
Posts: 4
jabarabara is an unknown quantity at this point
Problems with Morphology

So, in the past week I've been working on computer vision for this year's competition. I was able to create a binary image by thresholding an image for HSV ranges, but when I try to use morphology dilation I get an error

Code:
        NIVision.Image img, bin, morph;
	NIVision.RawData colorTable;
	
	final NIVision.Range HUE_RANGE = new NIVision.Range(213,255);
	final NIVision.Range SAT_RANGE = new NIVision.Range(217,255);
	final NIVision.Range VIS_RANGE = new NIVision.Range(102,204);
	
        public void robotInit() {
    	    	img = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
    	    	bin = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_U8, 0);
    	    	morph = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_U8, 0); 
    	    	colorTable = new NIVision.RawData();
        }

        public void operatorControl() {
    	    	NIVision.imaqReadFile(img, "/home/lvuser/capture.jpg");
    	    	NIVision.imaqColorThreshold(bin, img, 255, NIVision.ColorMode.HSV, HUE_RANGE, SAT_RANGE, VIS_RANGE);
    	    	NIVision.imaqWriteJPEGFile(bin, "/home/lvuser/bin.jpg", 2000, colorTable);
    	    	NIVision.imaqMorphology(morph, bin, NIVision.MorphologyMethod.DILATE, new NIVision.StructuringElement(3,3,1));
    	    	NIVision.imaqWriteJPEGFile(morph, "/home/lvuser/morph.jpg", 2000, colorTable);
        }
I got this error from the code above:

Code:
VisionException [com.ni.vision.VisionException: imaqError: -1232673104: Unknown error]
	at com.ni.vision.NIVision._imaqMorphology(Native Method)
	at com.ni.vision.NIVision.imaqMorphology(NIVision.java:24502)
	at org.usfirst.frc.team2415.robot.Robot.operatorControl(Robot.java:47)
	at edu.wpi.first.wpilibj.SampleRobot.startCompetition(SampleRobot.java:159)
	at edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:242)
I've already tried searching for the problem to find a solution and couldn't. I don't see what's wrong. Any ideas?
Reply With Quote