Frame not found?

I’ve posted about vision help before on here and what people were able to give me helped a ton. I’m extremely new to vision, fairly new to FIRST, and somewhat experienced with Java, so I’m obviously not the most experienced, but I’d love to figure this out. I have my pipeline and a command that should grab the frame from the camera, run it through the pipeline, and then calculate/set motor speeds. I’m getting this error, however

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /var/lib/jenkins/workspace/OpenCV-roborio/modules/imgproc/src/color.cpp, line 8000 
 Exception in thread "Thread-0" CvException [org.opencv.core.CvException: cv::Exception: /var/lib/jenkins/workspace/OpenCV-roborio/modules/imgproc/src/color.cpp:8000: error: (-215) scn == 3 || scn == 4 in function cvtColor 
 ] 
 	at org.opencv.imgproc.Imgproc.cvtColor_1(Native Method) 
 	at org.opencv.imgproc.Imgproc.cvtColor(Unknown Source) 
 	at org.usfirst.frc.team4750.robot.Robot.lambda$robotInit$0(Robot.java:58) 
 	at org.usfirst.frc.team4750.robot.Robot$$Lambda$2/17398621.run(Unknown Source) 
 	at java.lang.Thread.run(Thread.java:745)

and I can’t figure out how to fix it. I did some research and have concluded it’s not receiving a frame, but I don’t know why. Any help would be much appreciated. The code is at https://github.com/ngregrichardson/R2Vision if you don’t mind taking a look. Thanks!

I just fixed the same today on some code I was working on. Here’s what I ended up discovering in my case:

  1. CvSink.grabFrame(Mat frame) returns a long value. If that value is 0, there is an error.
  2. You can call CvSink.getError() and print the results to see what the error is.
  3. I was calling CameraServer.getInstance().getVideo()with no arguments and I was getting a timeout error when reading using grabFrame
  4. I changed the call to CameraServer.getInstance().getVideo() to pass the UsbCamera instance returned by CameraServer.startAutomaticCapture() and that solved my problem.

Hopefully this helps.