Corrupt jpg data when using OpenCv on roboRIO

Hello, we are trying to stream our usb camera image to a piece of open cv code on the robot using 2168’s vision library and example code. We have everything compiled successfully and running, however when we try to grab a frame from the camera it says:

Corrupt Jpeg data: x extraneous bytes. 0.07 seconds to capture frame.

I have a feeling this is because we had the same issue before when trying to get the camera frame from two different places. However, I dont see this being an issue unless the smart dashboard is automatically trying to get the camera image.

GitHub repo: code

Thanks, Drew.

Alright, we have solved our issue above, however we ran into another issue when saving an image from the sub camera to the roboRio. Whenever we save an image through converting the image to a mat and using imwrite, all we get is a uniform gray image. We can get a regular image to the smart dashboard using the camera server class without modification, but as soon as we bring it into Opencv, it breaks the image.

Any suggestions?