Search code examples
javaopencvjavacvopenni

Error 'ImageGenerator' cannot be resolve


I am trying the following code but getting:

ImageGenerator cannot be resolved

I have imported the required libraries of JavaCV and OpenCV. Do I need to import more libraries? I have searched, but could not find it!

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.nio.ByteBuffer;

import javax.naming.Context;

 enum Resolution {
      NORMAL, HIGH
    }


    public class KinectCapture 
    {
      private BufferedImage image = null;
      private int imWidth, imHeight;
      private int fps;

      private boolean isReleased = true;    
               // when Kinect context has been released

      // OpenNI
      private Context context;
      private ImageGenerator imageGen; **Here I am getting the error.**

      public KinectCapture()
      {  this(Resolution.NORMAL);  }

          public KinectCapture(Resolution res)
      {  configOpenNI(res); }


      private void configOpenNI(Resolution res)
      // create context and image generator
      {
        try {
          context = new Context();

          // add the NITE Licence 
          License licence = new License("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4=");   // vendor, key
          context.addLicense(licence); 

          imageGen = ImageGenerator.create(context);

Solution

  • I cant find ImageGenerator in the JavaDoc so im assuming you either have a package given to you by your school or whatever, then you have to import that as well, or you need to create the Class ImageGenerator somewhere in your package.

    EDIT: After some research, I found this: https://github.com/OpenNI/OpenNI/blob/master/Wrappers/OpenNI.java/src/org/openni/ImageGenerator.java