Go to Post Lesson learned: don't hide cables where drills can find them! - Richard Wallace [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 01-02-2013, 20:14
MLM's Avatar
MLM MLM is offline
Registered User
FRC #2502 (TalonRobotics)
Team Role: Webmaster
 
Join Date: Feb 2013
Rookie Year: 2009
Location: United States
Posts: 2
MLM is an unknown quantity at this point
WPICameraExtension Vision on PC/Laptop

Sooo I am trying to use all of the particleFilter and convexHull methods that ColorImage and BinaryImage has to offer.

I realize many people use findContours and all that stuff that goes with that but I want to use the great filters CriteriaCollection stuff.

The WPICameraExtension has WPIColorImage and WPIBinaryImage but there seems to be NO way to convert between the normal ColorImage and BinaryImage.

The only way I have figured out a way is if I save the rawImage
Code:
// Save file from camera for use
BufferedImage bi = rawImage.getBufferedImage();
File outputfile = new File("cameraOutput.jpg");
ImageIO.write(bi, "jpg", outputfile);
and then use
Code:
ColorImage image = new RGBImage("cameraOutput.jpg");
My problem is the RGBImage() seems to stall the program. It does not give any exception and does not run any code beneath it. RGBImage() is the method used in the camera test sample in netbeans.

Is there a way to make my own system to create a ColorImage? or how do I get around this issue?

Here is the reduced code that I am trying to use (Make sure to Run as Administrator):
Code:
import edu.wpi.first.smartdashboard.camera.WPICameraExtension;
import edu.wpi.first.wpijavacv.WPIColorImage;
import edu.wpi.first.wpijavacv.WPIImage;
import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.RGBImage;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class SimpleCameraExtension extends WPICameraExtension 
{
    public static final String NAME = "Simple Camera Extension";
    
    @Override
    public WPIImage processImage(WPIColorImage rawImage) 
    {
        // Save file from camera for use
        try
        {
            File outputfile = new File("cameraOutput.jpg");
            
            //ColorImage image = (ColorImage)rawImage;
            SmartDashboard.putString("testingBefore", "" + System.nanoTime());

            ColorImage image = new RGBImage("cameraOutput.jpg");

            outputfile.delete(); // testing
        
        }
        catch(Exception e)
        {
            SmartDashboard.putString("exceptionHere", "" + System.nanoTime());
        }

        return rawImage.getRedChannel();
    }
}

Include these jars:
\SmartDashboard\extensions\WPICameraExtension.jar
\SmartDashboard\extensions\lib\WPIJavaCV.jar
\SmartDashboard\SmartDashboard.jar
wpilibj.jar

Last edited by MLM : 02-02-2013 at 01:24.
Reply With Quote
 


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 10:04.

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