Ask Your Question

miller619's profile - activity

2020-06-12 07:19:44 -0600 received badge  Notable Question (source)
2019-05-20 20:44:05 -0600 received badge  Popular Question (source)
2017-09-25 05:15:11 -0600 received badge  Enthusiast
2017-09-22 15:18:11 -0600 asked a question Control the FPS of a video input OpenCV Android

Control the FPS of a video input OpenCV Android I am making an application where the camera takes a video and shows the

2017-09-22 08:58:05 -0600 marked best answer Opencv Android: FPS and RGB values [Solved]

hi, i am learning to use opencv in android application. I am trying to create an app that captures video. the purpose of it is that when i point my camera to a color, it should show me the rgb values separately and also show the fps at which it is capturing. i would also like to change the fps according to the device its used on. I have done tutorials and I know how to change RGB image to GREY scale and so on. However, i cannot understand that once i declare "inputFrame.rgba()" how the break it up and store the R, G and B values separately to show it on the log/screen and also display the fps at which the video is being captured.

  public class VideoRecordingActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{

//custom toolbar
private Toolbar toolbar;

//java camera view
JavaCameraView javaCameraView;

Mat mRgba, hsv_scale;





//callback loader
BaseLoaderCallback mCallBackLoader = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {


        switch (status){
            case BaseLoaderCallback.SUCCESS:
                javaCameraView.enableView();
                break;
            default:
                super.onManagerConnected(status);
                break;
        }
    }
};


public static String TAG="VideoRecordingActivity";
public static String TAG2="Video";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_recording);

    //custom toolbar
    toolbar = (Toolbar)findViewById(R.id.nav_action);
    setSupportActionBar(toolbar);


    //connect the camera
    javaCameraView = (JavaCameraView)findViewById(R.id.java_camera_view);

    //set visibility
    javaCameraView.setVisibility(SurfaceView.VISIBLE);
    javaCameraView.setMaxFrameSize(1024,768);
    javaCameraView.clearFocus();

    //set callback function
    javaCameraView.setCvCameraViewListener(this);


}

@Override
protected void onPause() {
    super.onPause();

    if(javaCameraView!=null){
        javaCameraView.disableView();
    }
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if (javaCameraView!=null){
        javaCameraView.disableView();
    }
}

@Override
protected void onResume() {
    super.onResume();

    if (OpenCVLoader.initDebug()){
        Log.d(TAG, "Connected");

        //display when the activity resumed,, callback loader
        mCallBackLoader.onManagerConnected(LoaderCallbackInterface.SUCCESS);


    }else{
        Log.d(TAG, "Not connected");
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_3_0, this, mCallBackLoader);
    }
}

@Override
public void onCameraViewStarted(int width, int height) {
    //4 channel
    mRgba = new Mat(height, width, CvType.CV_8UC4);
    hsv_scale = new Mat(height, width, CvType.CV_8UC1);


}

@Override
public void onCameraViewStopped() {
    //release
    mRgba.release();
}

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    //camera setup

    //get each frame from camera
    mRgba = inputFrame.rgba();

    Vector<Mat> channels = null;

    Core.split(mRgba, channels);

    int rows = mRgba.rows();
    int cols = mRgba.cols();

    double R=0,G=0,B=0;

    for (int i=0; i<rows; i++)
    {
        for (int j=0; j<cols; j++)
        {
            double[] data = mRgba.get(i, j); //Stores element in an array
            R = data[0];
            G= data[1];
            B = data[2];
        }
    }
    Imgproc.putText(mRgba,"R:"+R + "G:"+G +"B:"+B,new Point(10,52),Core.FONT_HERSHEY_COMPLEX,.7,new Scalar(5,255,255), 2,8,false );
    return mRgba;

}

This is my camera class. In the onCameraFrame class you may notice that i have declared rows and columns to break this color space into RGB and this works fine. Except it drastically decrees the FPS of my video.

What am i missing. I would like to have suggestions/direction on how to achieve what im trying to get.

Thank you

2017-09-22 08:58:03 -0600 received badge  Self-Learner (source)
2017-09-22 08:57:51 -0600 received badge  Student (source)
2017-09-21 15:37:49 -0600 edited answer Opencv Android: FPS and RGB values [Solved]

@Override public void onCameraViewStarted(int width, int height) { //4 channel mRgba = new Mat(width, height

2017-09-21 15:37:37 -0600 edited question Opencv Android: FPS and RGB values [Solved]

Opencv Android: FPS and RGB values [Solved] hi, i am learning to use opencv in android application. I am trying to creat

2017-09-21 15:37:32 -0600 received badge  Editor (source)
2017-09-21 15:37:32 -0600 edited question Opencv Android: FPS and RGB values [Solved]

Opencv Android: FPS and RGB values hi, i am learning to use opencv in android application. I am trying to create an app

2017-09-21 15:36:57 -0600 answered a question Opencv Android: FPS and RGB values [Solved]

@Override public void onCameraViewStarted(int width, int height) { //4 channel mRgba = new Mat(width, height

2017-09-18 10:36:31 -0600 commented question Opencv Android: FPS and RGB values [Solved]

my apologies... I have been trying to get there for like 3 days now... there is nothing i did not try.. i found some clu

2017-09-18 10:28:07 -0600 commented question Opencv Android: FPS and RGB values [Solved]

my apologies... I have been trying to get there for like 3 days now... there is nothing i did not try.. i found some clu

2017-09-18 10:26:03 -0600 commented question Opencv Android: FPS and RGB values [Solved]

my apologies... I have been trying to get there for like 3 days now... there is nothing i did not try.. i found some clu

2017-09-18 05:45:04 -0600 commented question Opencv Android: FPS and RGB values [Solved]

The problem is i just want to display the R,G and B numeric values when i point my camera to certain color. for example

2017-09-18 05:25:42 -0600 commented question Opencv Android: FPS and RGB values [Solved]

thanks for telling me not to access the pixel. i got it the first time you said it.. and i posted this question in the f

2017-09-18 04:02:29 -0600 commented question Opencv Android: FPS and RGB values [Solved]

i tried splitting the channels like this but the problem is when i log the value or red blue or green i get List&l

2017-09-18 04:02:10 -0600 commented question Opencv Android: FPS and RGB values [Solved]

i tried splitting the channels like this nut the problem is when i log the value or red blue or green i get List&l

2017-09-18 04:01:33 -0600 commented question Opencv Android: FPS and RGB values [Solved]

List<mat> channels = new ArrayList<mat>(); Core.split(mRgba, channels); red = channels.get(0

2017-09-18 04:01:10 -0600 commented question Opencv Android: FPS and RGB values [Solved]

List<mat> channels = new ArrayList<mat>(); Core.split(mRgba, channels); red = channels.get(0

2017-09-18 04:00:53 -0600 commented question Opencv Android: FPS and RGB values [Solved]

List<mat> channels = new ArrayList<mat>(); Core.split(mRgba, channels); red = channels.get(0

2017-09-17 12:31:17 -0600 commented question Opencv Android: FPS and RGB values [Solved]

I have been going through the JavaCameraView.java class and found that i can call a method called "enableFpsMeter()" to

2017-09-17 12:20:58 -0600 asked a question Opencv Android: FPS and RGB values [Solved]

Opencv Android: FPS and RGB values hi, i am learning to use opencv in android application. I am trying to create an app