Ask Your Question

2D3D's profile - activity

2018-07-05 09:59:37 -0600 received badge  Notable Question (source)
2017-11-20 03:14:30 -0600 received badge  Popular Question (source)
2016-05-16 08:07:57 -0600 asked a question VideoWriter - Android cant create a video properly

Hello , I have a code which takes a buffer of mats and should create a video from it here is the code

File sdCard = Environment.getExternalStorageDirectory();
        writingVideo = true;
        goal_counter = goal_counter + 1;
        VideoWriter vw = new VideoWriter(sdCard.getAbsolutePath() + "/ran/" + "goal" + goal_counter + ".avi", VideoWriter.fourcc('M','J','P','G') , 50, size);
        for(int i=0;i<buffer.size();i++)
        {
            vw.write(buffer.get(i));
        }
       // vw.release();
        Log.d("Video","Successful - "+ sdCard.getAbsolutePath() + "/ran/" + "goal" + goal_counter + ".avi");

The problem is when i try to play this video on my computer it is either to fast or too short and doesnt contain all the images it is given , any suggestions?

2016-05-13 07:27:45 -0600 asked a question Saving a buffer of mat to a video

have a buffer which has the Mats from which i want to create a video

I transform those mats into byte array and write them to the outputstream yet for some reason whenever I watch the video only one image is shown heres the code

try {
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath() + "/ran");
dir.mkdirs();
File file = new File(dir, "goal_ran.mp4");
FileOutputStream out = new FileOutputStream(file);

for(int i=0;i<buffer.size();i++)
{

    Mat mat = buffer.get(i);
    MatOfByte matOfByte = new MatOfByte();
    Imgcodecs.imencode(".png", mat, matOfByte);
    byte[] byteArray = matOfByte.toArray();
    out.write(byteArray);
    out.flush();
    /*byte[] return_buff = new byte[(int) (buffer.get(i).total() * buffer.get(i).elemSize())];
    buffer.get(i).get(0, 0, return_buff);*/
    /*int length = (int) (mat.total() * mat.elemSize());
    byte buffer[] = new byte[length];
    mat.get(0, 0, buffer);
    out.write(buffer);*/
}

out.close();
Log.d("Video","Successful"+ buffer.size());



} catch (Exception e) {
    e.printStackTrace();
}
2016-04-27 02:32:48 -0600 asked a question Deciding if a ball is inside a goal via Image Processing

i have an app which can track the ball perfectly at all time

I want to know if a ball is inside a goal , The problem I am facing is how to decide it when you have only a 2d vision of the goal and there is a situation like this enter image description here mimage description

Even as a human its difficult for me to decide whether this ball is inside a goal or not, are there any algorithms or Image processing tricks that ight help?

2016-04-13 04:32:19 -0600 asked a question Android - Opencv - error: (-215) u != 0 in function void cv::Mat::create

My app keeps crashing with this error

FATAL EXCEPTION: Thread-22883
                                                             Process: com.aar.Cline, PID: 7270
                                                             CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/matrix.cpp:424: error: (-215) u != 0 in function void cv::Mat::create(int, const int*, int)
                                                             ]
                                                                 at org.opencv.imgproc.Imgproc.cvtColor_1(Native Method)
                                                                 at org.opencv.imgproc.Imgproc.cvtColor(Imgproc.java:1724)
                                                                 at com.aar.Cline.TrackBallActivity.detectBall(TrackBallActivity.java:592)
                                                                 at com.aar.Cline.TrackBallActivity.onCameraFrame(TrackBallActivity.java:190)
                                                                 at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391)
                                                                 at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:350)
                                                                 at java.lang.Thread.run(Thread.java:818)

The app is running fine for about 3 min when suddenly in the middle this error shows up here is the line on which it keeps crashing

Mat grayImage1 = new Mat();
Imgproc.cvtColor(frame1, grayImage1, Imgproc.COLOR_BGR2GRAY);

Any suggestions?