NOTE: SDK v9.0+ is required to use this
NOTE: an OpenRC-based SDK is NOT required to use this
Finally, a straightforward and easy way to use OpenCV on an FTC robot! With this library, you can go from a stock SDK to running a sample OpenCV OpMode, with either an internal or external camera, in just a few minutes!
Features at a glance:
Unfortunately, due to a known bug with OpenCV 4.x, EasyOpenCV is only compatible with devices that run Android 5.0 or higher. For FTC, this means that it is incompatible with the ZTE Speed. EasyOpenCV will work fine on all other FTC-legal devices (including the new Control Hub).
IMPORTANT NOTE: EasyOpenCV delivers RGBA frames, but desktop OpenCV (what you may be used to) delivers BGR frames. Beware when porting code between the two!
As of FTC SDK v8.2, EasyOpenCV is now packaged with the SDK as part of the Vision module. No manual installation is neccesary whether you are using Android Studio or Blocks.
PLEASE NOTE THAT THERE IS CURRENTLY A KNOWN BUG IN v9.0 and v9.0.1 OF THE FTC SDK WHICH PREVENTS IMPORTING THE OpenCvCameraFactory CLASS IN OBJ
VisionProcessor and use the Vision Portal API. There is a chapter in the LearnJava4FTC book that covers thislibjpeg-turbo to 3.0.3NATIVE_VIEW viewport renderer option
SOFTWARE renderer and the speedup seen with the GPU_ACCELERATED rendererGPU_ACCELERATED renderer doesrequestViewportDrawHook(object) during processFrame(), providing any type of context object they may wish which encapsulates the data needed to draw the annotations. Pipelines then also need to override onDrawFrame(...) which can receive that same object back, and perform the annotation drawing there.startStreaming() method in OpenCvWebcam which takes a StreamFormat argumentOpenCvSwitchableWebcam4.7.0-AgetControl() method to OpenCvWebcamstartStreaming() after a previous call to stopStreaming() even though the stream was in fact restarted successfully (#65)opencv-repackaged updated to 4.5.3-B)
onOpened() callback would be called even in the case of failure)
AsyncCameraOpenListener instances must now also implement the void onError(int errorCode) functionvoid setMillisecondsPermissionTimeout(int ms) added)org.firstinspires.ftc.teamcode packagesaveMatToDiskFullPath() method to pipeline classTimestampedOpenCvPipeline class which extends OpenCvPipeline and delivers capture time timestamps along with frames. See new TimestampedPipelineExample file.memcpy operationsOpenCvInternalCamera2 interface. Camera2 instances can be obtained from OpenCvCameraFactory, just like other typesOpenCvCamera interface extend CameraStreamSource so that casting to implementation objects isn't required to use a camera as a stream source for something other than the DSsetViewportRenderingPolicy() API to OpenCvCamera interface, provides option to:
MAXIMIZE_EFFICIENCY Keep viewport behavior as it always has been, OROPTIMIZE_VIEW At the expense of CPU time (and viewport smoothness), automatically orient preview image such that it's not constantly 90 degrees out from expected with an internal camera when the physical device orientation does not match the streaming orientationinit(Mat m) method to pipeline class, which will be called with the first frame from the camera, allowing you to initialize submats and the like for your pipelinestuckInXYZ() issues and the like. Please consult the OpenCvCamera interface javadoc for detailsOpenCvSwitchableWebcam interface. Instances can be obtained from OpenCvCameraFactory, just like other typesOpenCvWebcam interface which exposes some additional functionality for webcams
OpenCvCameraFactory, just like other typesOpenCvCameraFactory.getInstance().create...extends OpenCvPipeline instead of implements OpenCvPipelineonViewportTapped() to be notified if the user taps the viewportPipelineStageSwitchingExample to show how to use onViewportTapped() to change which stage of your pipeline is drawn to the viewport for debugging purposes. It also shows how to get data from your pipeline to your OpMode.Java
94.4%
C++
4.4%
NOTE: SDK v9.0+ is required to use this
NOTE: an OpenRC-based SDK is NOT required to use this
Finally, a straightforward and easy way to use OpenCV on an FTC robot! With this library, you can go from a stock SDK to running a sample OpenCV OpMode, with either an internal or external camera, in just a few minutes!
Features at a glance:
Unfortunately, due to a known bug with OpenCV 4.x, EasyOpenCV is only compatible with devices that run Android 5.0 or higher. For FTC, this means that it is incompatible with the ZTE Speed. EasyOpenCV will work fine on all other FTC-legal devices (including the new Control Hub).
IMPORTANT NOTE: EasyOpenCV delivers RGBA frames, but desktop OpenCV (what you may be used to) delivers BGR frames. Beware when porting code between the two!
As of FTC SDK v8.2, EasyOpenCV is now packaged with the SDK as part of the Vision module. No manual installation is neccesary whether you are using Android Studio or Blocks.
PLEASE NOTE THAT THERE IS CURRENTLY A KNOWN BUG IN v9.0 and v9.0.1 OF THE FTC SDK WHICH PREVENTS IMPORTING THE OpenCvCameraFactory CLASS IN OBJ
VisionProcessor and use the Vision Portal API. There is a chapter in the LearnJava4FTC book that covers thislibjpeg-turbo to 3.0.3NATIVE_VIEW viewport renderer option
SOFTWARE renderer and the speedup seen with the GPU_ACCELERATED rendererGPU_ACCELERATED renderer doesrequestViewportDrawHook(object) during processFrame(), providing any type of context object they may wish which encapsulates the data needed to draw the annotations. Pipelines then also need to override onDrawFrame(...) which can receive that same object back, and perform the annotation drawing there.startStreaming() method in OpenCvWebcam which takes a StreamFormat argumentOpenCvSwitchableWebcam4.7.0-AgetControl() method to OpenCvWebcamstartStreaming() after a previous call to stopStreaming() even though the stream was in fact restarted successfully (#65)opencv-repackaged updated to 4.5.3-B)
onOpened() callback would be called even in the case of failure)
AsyncCameraOpenListener instances must now also implement the void onError(int errorCode) functionvoid setMillisecondsPermissionTimeout(int ms) added)org.firstinspires.ftc.teamcode packagesaveMatToDiskFullPath() method to pipeline classTimestampedOpenCvPipeline class which extends OpenCvPipeline and delivers capture time timestamps along with frames. See new TimestampedPipelineExample file.memcpy operationsOpenCvInternalCamera2 interface. Camera2 instances can be obtained from OpenCvCameraFactory, just like other typesOpenCvCamera interface extend CameraStreamSource so that casting to implementation objects isn't required to use a camera as a stream source for something other than the DSsetViewportRenderingPolicy() API to OpenCvCamera interface, provides option to:
MAXIMIZE_EFFICIENCY Keep viewport behavior as it always has been, OROPTIMIZE_VIEW At the expense of CPU time (and viewport smoothness), automatically orient preview image such that it's not constantly 90 degrees out from expected with an internal camera when the physical device orientation does not match the streaming orientationinit(Mat m) method to pipeline class, which will be called with the first frame from the camera, allowing you to initialize submats and the like for your pipelinestuckInXYZ() issues and the like. Please consult the OpenCvCamera interface javadoc for detailsOpenCvSwitchableWebcam interface. Instances can be obtained from OpenCvCameraFactory, just like other typesOpenCvWebcam interface which exposes some additional functionality for webcams
OpenCvCameraFactory, just like other typesOpenCvCameraFactory.getInstance().create...extends OpenCvPipeline instead of implements OpenCvPipelineonViewportTapped() to be notified if the user taps the viewportPipelineStageSwitchingExample to show how to use onViewportTapped() to change which stage of your pipeline is drawn to the viewport for debugging purposes. It also shows how to get data from your pipeline to your OpMode.Java
94.4%
C++
4.4%