OpenFTC / OpenRC_2017-18

An easily modifiable version of the FIRST Tech Challenge robot controller Android app
http://openftc.org/OpenRC
18 stars 13 forks source link

Ease OpenCV development #6

Closed NoahAndrews closed 5 years ago

NoahAndrews commented 6 years ago

I don't have any experience here, so this will have to be contributed by someone else.

WardBenjamin commented 6 years ago

Realistically, the only way to add OpenCV support is by modifying the FtcRobotControllerActivity. I've pushed a copy with OpenCV support to the opencv branch of my fork but I have a few issues:

And I'm sure there's a whole other list of issues as well. As of right now, the setup is very similar to that done by LASA Robotics and the electronVolts but I think it could be improved a lot.

Thoughts?

Windwoes commented 6 years ago

I don't see why it needs to go in the FtcRobotController activity.... why can't it be a separate class used from an OpMode?

WardBenjamin commented 6 years ago

@FROGbots-4634 Most of the code can, but if we want to view the camera feed as per Vuforia you need to hook into the activity layout. There is a way to do that dynamically but it still requires hooks into the activity.

nicholasday commented 6 years ago

I've hooked into it dynamically without modifying the FtcRobotController activity.

You can write to a surfaceview that is added to the R.cameraMonitorViewId during init of an OpMode:

        context = hardwareMap.appContext;
        final Activity activity = (Activity) hardwareMap.appContext;

        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                LinearLayout l = (LinearLayout) activity.findViewById(R.id.cameraMonitorViewId);
                surfaceView = new MySurfaceView(context, WIDTH, HEIGHT);
                l.addView(surfaceView);
            }
        });
Windwoes commented 5 years ago

EasyOpenCV is now a thing