unable to compile camera code

After searching forums and docs we are still unable to build the code taken from the WPI user guide. I am using Netbeans, have plugins installed, and installed smartdashboard. I am trying to compile following code from user guide:

package com.crimsonrobotics;

import edu.wpi.first.smartdashboard.camera.WPICameraExtension;
import edu.wpi.first.wpijavacv.WPIColorImage;
import edu.wpi.first.wpijavacv.WPIImage;

/**
*

  • @author
  • Wayne
    */
    public class BasicCameraExtension extends WPICameraExtension {
    //@Override
    public WPIImage processImage(WPIColorImage rawImage) {
    return rawImage.getRedChannel();
    }
    }

here are errors I get:

C:\Users\Wayne\Documents\NetBeansProjects\Team2526Version5\src\com\crimsonrobotics\BasicCameraExtension.java:7: package edu.wpi.first.smartdashboard.camera does not exist
import edu.wpi.first.smartdashboard.camera.WPICameraExtension;
C:\Users\Wayne\Documents\NetBeansProjects\Team2526Version5\src\com\crimsonrobotics\BasicCameraExtension.java:8: package edu.wpi.first.wpijavacv does not exist
import edu.wpi.first.wpijavacv.WPIColorImage;
C:\Users\Wayne\Documents\NetBeansProjects\Team2526Version5\src\com\crimsonrobotics\BasicCameraExtension.java:9: package edu.wpi.first.wpijavacv does not exist
import edu.wpi.first.wpijavacv.WPIImage;
C:\Users\Wayne\Documents\NetBeansProjects\Team2526Version5\src\com\crimsonrobotics\BasicCameraExtension.java:16: cannot find symbol
symbol: class WPICameraExtension
public class BasicCameraExtension extends WPICameraExtension {
C:\Users\Wayne\Documents\NetBeansProjects\Team2526Version5\src\com\crimsonrobotics\BasicCameraExtension.java:18: cannot find symbol
symbol : class WPIColorImage
location: class com.crimsonrobotics.BasicCameraExtension
public WPIImage processImage(WPIColorImage rawImage) {
C:\Users\Wayne\Documents\NetBeansProjects\Team2526Version5\src\com\crimsonrobotics\BasicCameraExtension.java:18: cannot find symbol
symbol : class WPIImage
location: class com.crimsonrobotics.BasicCameraExtension
public WPIImage processImage(WPIColorImage rawImage) {
6 errors
C:\Users\Wayne\sunspotfrcsdk\ant\compile.xml:48: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

Once we get past this we can be on our way. Any sugestions? I tried to add jars in all places I could to no avail.

I’m guessing that you haven’t added the SmartDashboard JAR files to your NetBeans project. Here are my suggestions:

  • Right click on your project in the NetBeans project browser (left side navigation) and select properties
  • Select the “Libraries” category
  • Click on the “Add Library” button, then click the “Create” button and add a library named “SmartDashboard”
  • You will then be asked to add a collection of JAR files to include in the library.
  • Click the “Add JAR/Folder” button, and the SmartDashboard.jar file (look under “C:\Program Files\SmartDashboard”).
  • Click the “Add JAR/Folder” button, and the WPICameraExtension.jar file (look under “C:\Program Files\SmartDashboard\extensions”).
  • Click the “Add JAR/Folder” button, and the javacpp.jar file (look under “C:\Program Files\SmartDashboard\extensions\lib”).
  • Click the “Add JAR/Folder” button, and the javacv-windows-x86.jar file (look under “C:\Program Files\SmartDashboard\extensions\lib”).
  • Click the “Add JAR/Folder” button, and the javacv.jar file (look under “C:\Program Files\SmartDashboard\extensions\lib”).
  • Click the “Add JAR/Folder” button, and the WPIJavaCV.jar file (look under “C:\Program Files\SmartDashboard\extensions\lib”).

This should include all of the JAR files necessary to work on SmartDashboard plugins and driver station side image processing.

If you decide to create additional SmartDashboard projects, you should just be able to select the new “SmartDashboard” library we created above (you won’t have to add all of the JAR files again).

NOTE: We ran across a memory leak in the WPIJavaCV.jar file that causes the system to run out of memory and crash after processing too many images. There was a fix - but I’m not sure it’s been pushed out. If you find your program crashing, use Window’s Task Manager to observe it when running and see if it consumes a lot of memory when running. If so, you may want to refer to this post:

It has a unofficial replacement for the WPIJavaCV.jar file which was built from the updated source files at the SmartDashboard project.

Our code is based on the command Base template and when you right click on the project in the left pane libraries is not an option. Is this because it is a freeform project? Does the camera code go in as another class in this project? I am trying to follow the user guide and we are stuck at this point any help appreciated. If others are doing it this way then somewhere along the line we missed something.

You can’t create a SmartDashboard extension in the same project that you create robot code. (as far as I know)
You must create the project as a Java Class Library so that you can compile it as a .jar extension.