Ask Your Question

VPallavi's profile - activity

2019-01-24 06:42:36 -0500 received badge  Famous Question (source)
2018-08-24 06:42:02 -0500 received badge  Popular Question (source)
2018-04-06 08:44:03 -0500 received badge  Student (source)
2018-01-02 05:48:17 -0500 commented question Error creating CvSVM in Java with OpenCV 2.4.13

Hey, I am also getting the same error message. Did you solve the error?

2018-01-02 05:47:52 -0500 answered a question Error creating CvSVM in Java with OpenCV 2.4.13

Hey, I am also getting the same error message. Did you solve the error?

2017-08-17 00:15:57 -0500 received badge  Notable Question (source)
2017-06-20 10:56:44 -0500 received badge  Popular Question (source)
2017-04-18 02:10:05 -0500 commented question How to extract all the frames from a video in android?

ok. thank you.

2017-04-18 02:02:30 -0500 commented question How to extract all the frames from a video in android?

Ok. Is there any way of doing this using OpenCV library? If not, could you please reply in following link: http://stackoverflow.com/questions/42945717/frames-extraction-from-a-video-using-mediametadataretriever-is-not-working-fine (http://stackoverflow.com/questions/42...) ?

2017-04-18 01:43:44 -0500 asked a question How to extract all the frames from a video in android?

I want to extract all the frames from a video (15fps) of 3 seconds in Android. I used 'medimetadataretriever' class for this. I'm getting two frames repeated for all the frames. My code is as follows:

 public int Detect (String recordedFilePath)
    {
    File videoFile=new File(recordedFilePath);
    Uri videoFileUri=Uri.parse(videoFile.toString());
    MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
    mediaMetadataRetriever.setDataSource(videoFile.getAbsolutePath());
    ArrayList<Bitmap> rev = new ArrayList<Bitmap>();
    ArrayList<Mat> imgMAT = new ArrayList<Mat>();
    MediaPlayer mp = MediaPlayer.create(getBaseContext(), videoFileUri);
    int millis = mp.getDuration();  
    for (long index2 = 0 ; index2 < millis*1000 ; index2=index2+66666)
    {
    Bitmap barray = mediaMetadataRetriever.getFrameAtTime(index2, MediaMetadataRetriever.OPTION_CLOSEST);
       rev.add(barray);
       try {
            saveFrames(rev);
       }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
    mediaMetadataRetriever.release();
    return 0;
    }
        public void saveFrames(ArrayList<Bitmap> saveBitmapList) throws IOException{

        String folder = Environment.getExternalStorageDirectory().toString();
        File saveFolder = new File(fpath +"/new/");
        if(!saveFolder.exists()){
           saveFolder.mkdirs();
        }
        int i=1;
        for (Bitmap b : saveBitmapList){
           ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            b.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
            File f = new File(saveFolder,("frame"+i+".jpg"));
            f.createNewFile();
            FileOutputStream fo = new FileOutputStream(f);
            fo.write(bytes.toByteArray());
               fo.flush();
               fo.close();
               i++;
        }
    }

Please help me. Thanks in advance!

2016-12-12 07:40:59 -0500 commented answer Nested if-else conditions

@Balaji R:: The code is same only that I posted in question. The point where I'm stuck is that inside the second for loop it is not going under any if-else condition. I put Log.d statements under each if-else but not a single statement is printed. To be more precise, I'm trying to construct GLCM(Gray Level Co-occurance Matrix) with the pixels of "gray" image (Mat type variable). For doing this I need to divide 0-255 into 8 bins by alloting 0-31 as 1, 32-63 as 2,....and so on. I hope it is clear now.

2016-12-12 05:00:36 -0500 commented answer Nested if-else conditions

@Balaji R:: Actually I'm writing code in android using OpenCV library. In C++ I wrote the following code and it's working fine.

          `Mat fin = new Mat (gray.size(),CvType.CV_8UC3, new Scalar(0,0,0));
                         for (int ii=0;ii<rows;ii++)
                     {
                         for (int j=0;j<cols;j++)
                             {
                              fin.get(ii,j)[0]=(gray.get(ii,j)[0]/32)+1;
                                  Log.d("gray value:: ", "" +gray.get(ii,j)[0]);
                                      }
                     }`

But I'm unable to get correct result in android. Can you please help me in this regard. Thanks!

2016-12-12 01:19:05 -0500 commented question Nested if-else conditions

@pi-null-mezon:: The second one is also not working.

2016-12-12 01:07:09 -0500 commented question Nested if-else conditions

@LBerger:: I tried with this earlier but getting all values as zero.

                  fin.get(ii,j)[0]=(gray.get(ii,j)[0]/32)+1;
2016-12-12 01:02:04 -0500 commented question Nested if-else conditions

@pi-null-mezon:: This get() method is used for fetching the respective location. I got it from this forum only earlier.

2016-12-12 00:58:34 -0500 commented question Nested if-else conditions

@Balaji R:: I am trying to divide 256 pixels values into 8 bins. Just like normalization.

2016-12-11 23:23:47 -0500 asked a question Nested if-else conditions

Hello All...I know this is very small and stupid doubt but I don't know why I'm getting stuck here. I am using nested if-else loops inside "for" loop in my code but it at all not going inside this "for" loop. I checked it by putting Log.d statements inside each condition but none of then are getting printed. My block of code is as follows:

         Mat fin = new Mat (gray.rows(), gray.cols(), CvType.CV_8UC3);
         for (int ii=0;ii<rows;ii++)
        {
            for (int j=0;j<cols;j++)
            {
                if ( gray.get(ii, j)[0] < 32)
                {
                    fin.get(ii, j)[0] = 1;
                }
                else if (gray.get(ii, j)[0]>31 && gray.get(ii, j)[0] < 64)
                {
                    fin.get(ii, j)[0] = 2;
                }
                else if (gray.get(ii, j)[0] > 63 && gray.get(ii, j)[0] < 96)
                {
                    fin.get(ii, j)[0] = 3;
                }
                else if (gray.get(ii, j)[0] > 95 && gray.get(ii, j)[0] < 128)
                {
                    fin.get(ii, j)[0] = 4;
                }
                else if (gray.get(ii, j)[0] > 127 && gray.get(ii, j)[0] < 160)
                {
                    fin.get(ii, j)[0] = 5;
                }
                else if (gray.get(ii, j)[0] > 159 && gray.get(ii, j)[0] < 192)
                {
                    fin.get(ii, j)[0] = 6;
                }
                else if (gray.get(ii, j)[0] > 191 && gray.get(ii, j)[0] < 224)
                {
                    fin.get(ii, j)[0] = 7;
                }
                else if (gray.get(ii, j)[0] > 223 && gray.get(ii, j)[0] < 256)
                {
                    fin.get(ii, j)[0] = 8;
                }
                     }
            }

Please help!! Thanks in advance!!

2016-12-09 07:19:14 -0500 commented question Cropping a portion from a Mat image.

@berak:: I checked, image is loading. I just removed "Imgproc.cvtColor" line and it worked. I didn't understand why is it so.

2016-12-07 00:45:18 -0500 received badge  Editor (source)
2016-12-07 00:34:37 -0500 asked a question Cropping a portion from a Mat image.

Hello All...I am building an application (in Android using OpenCV library) in which cropping a portion from a Mat type image is required. When I'm running the application it's getting crashed by throwing NullPointerException. My code is as follows:

   nim = Highgui.imread(fpath+"/new/frame" +i+ ".jpg");
   Rect roi = new Rect(x, y, width, height);
   Mat cropped = new Mat(nim, roi);
   Imgproc.cvtColor(cropped, gray, Imgproc.COLOR_RGB2GRAY);

Here x=120, y=120, height=351, width=481; The correspoding logcat is shown below:image description

Please tell where I'm going wrong?? Thanks in advance.

2016-03-16 00:37:54 -0500 commented answer Displaying processed image on screen

@berak: Sorry for replying too late.. In this image should already be stored in some folder like drawable. But in my case image is stored in sdcard (which is just being processed). So how to display that??

2016-03-08 01:32:08 -0500 asked a question Displaying processed image on screen

Hello all!!

I'm working on an Android project with OpenCV library on Eclipse Platform. In this project I'm stuck at a point where I need to display the Mat image on the screen after it has been processed.

Overview: 1. Browsing an image from the phone. 2. Performing certain processing on it. 3. Saving the result image file in the same folder.

Now, after the first 2 processes I want to display the result image on the screen. I'm able to save it in the same folder but unable to display.

Please help me!!

2015-12-02 01:18:20 -0500 commented question Finding sum of all pixel values of a gray image

I need to find in java.

2015-12-02 00:48:49 -0500 asked a question Finding sum of all pixel values of a gray image

I want to find the sum of all pixel values of a gray image(Mat type). For that i need to access each pixel's intensity value. How can I do this in java? I'm using opencv library with it. In OpenCV we can use the following code:

for(int j=r.y;j<(r.y+r.height);j++)
    {
      for (int i=r.x;i<(r.x+r.width);i++)
      {
         int d= gray_image.at<uchar>(j,i);
         sum+=d;
      }
    }

Please suggest a solution to code it in java. Thanks!! I have tried it by using "Raster" as follows:

Raster raster = Gray_image.getRaster();

but I'm getting following error: The method getRaster() is undefined for the type Mat

Please help me!!

2015-07-16 04:42:22 -0500 commented question Saving image back to sdcard after processing in Android+OpenCV

Thank you so much :)

2015-07-16 04:16:57 -0500 commented question Saving image back to sdcard after processing in Android+OpenCV

I used imwrite also but got following error::

07-16 11:22:19.924: E/cv::error()(32492): OpenCV Error: Unspecified error (could not find a writer for the specified extension) in bool cv::imwrite_(const string&, const cv::Mat&, const std::vector<int>&, bool), file /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/highgui/src/loadsave.cpp, line 275 07-16 11:22:19.934: E/org.opencv.highgui(32492): highgui::imwrite_11() caught cv::Exception: /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/highgui/src/loadsave.cpp:275: error: (-2) could not find a writer for the specified extension in function bool cv::imwrite_(const string&, const cv::Mat&, const std::vector<int>&, bool)

2015-07-16 00:12:18 -0500 asked a question Saving image back to sdcard after processing in Android+OpenCV

I want to save the image after processing it, into the same location in sdcard. Initially I converted the image into 'Mat' for processing and now if I'm writing it directly into the same location but it's saving as a file containing some random values. I'm using the following code for writing.

private void write(String fpath, String fname, Mat image, boolean mode) {
// TODO Auto-generated method stub
try {
    File savefile = new File(fpath, "/"+fname);
    FileOutputStream fout = null;
    try {
        fout = new FileOutputStream(savefile,mode);
    } catch (FileNotFoundException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    PrintWriter pr = new PrintWriter(fout);
    for (int i = 0; i < image.width(); i++){
        for(int j = 0; j < image.height(); j++)
        {
        pr.print(image+"," );
        //pr.print("\n");
    }
    }

    pr.close();
} catch (Exception e) {
    e.printStackTrace();
}

}

2015-07-15 07:07:55 -0500 received badge  Enthusiast
2015-07-09 02:41:05 -0500 commented question Issue in Mat type in Android+OpenCV

Thank you for your answer as well as suggestion.

2015-07-09 02:19:32 -0500 commented question Issue in Mat type in Android+OpenCV

Still it's printing null.

2015-07-09 01:33:50 -0500 asked a question Issue in Mat type in Android+OpenCV

double[] labels = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; Mat labelsMat = new Mat(10,1, CvType.CV_32FC1); labelsMat.put(10, 1, labels); Log.d("Value of labels Mat is:: ",""+labelsMat.get(10, 1));

It's printing Null for labelsMat. Can anyone please tell me where i'm doing wrong?

2015-06-25 02:41:09 -0500 commented answer Detect faces on an image in Android OpenCV java

mNativeDetector.detect(mGray, faceDetections);

getting error:: The method detect(Mat, MatOfRect) is undefined for the type DetectionBasedTracker

Please help. Thank you!

2015-06-02 00:32:28 -0500 asked a question I'm unable to add OpenCV library in my Eclipse.

I'm unable to add OpenCV library in my Eclipse. Please help. Thank you!