Ask Your Question

Murad's profile - activity

2019-01-25 06:45:56 -0600 received badge  Popular Question (source)
2013-02-21 04:27:57 -0600 asked a question Problem in grabbing Image using Opencv2.1 and JavaCV

I have written program in c++ and also in Java using OpenCV and JavaCV but i am facing problem in order to grab image from H.264 IP Camera. my written program in C++ and Java are following:-

1)in C++ language written :-

#include <iostream>
#include "cv.h"
#include "highgui.h"
#include "cvaux.h"

using namespace std;

int main()
{

    CvCapture* capture = cvCaptureFromFile("rtsp://192.168.112.54:554/H264");
    cout<<" i am going to capture image "<<endl;


      while ( 1 ) {
     // Get one frame

     IplImage* frame = cvQueryFrame( capture );

     cout<<"i captured a frame "<<endl;
     if ( !frame ) {
       fprintf( stderr, "ERROR: frame is null...\n" );
       getchar();
       break;
     }
     cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
     cvShowImage( "mywindow", frame );

     if ( (cvWaitKey(10) & 255) == 27 ) break;
   }
   // Release the capture device housekeeping
   cvReleaseCapture( &capture );
   cvDestroyWindow( "mywindow" );
   cout << "Hello world!" << endl;
    return 0;

}

2.) in Java language written

import name.audet.samuel.javacv.OpenCVFrameRecorder;
import  com.sun.jna.*;
import  name.audet.samuel.javacv.jna.*;
import  name.audet.samuel.javacv.FrameGrabber;
import  name.audet.samuel.javacv.OpenCVFrameGrabber;
import static name.audet.samuel.javacv.jna.cv.v21.*;
import static name.audet.samuel.javacv.jna.cvaux.v21.*;
import static name.audet.samuel.javacv.jna.cxcore.v21.*;
import static name.audet.samuel.javacv.jna.highgui.*;
public class Recording {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        // TODO code application logic here
     // IplImage inputimage = null;  
     OpenCVFrameGrabber grabber = new OpenCVFrameGrabber("rtsp://192.168.112.54:554/H264");

     System.out.println("connection has been established");
      grabber.start();
      System.out.println("i am going to start");
      int key=0;

    IplImage inputimage = grabber.grab();
     System.out.println("now i am going to grab images");
     int width  = inputimage.width;
     int height = inputimage.height;
     cvShowImage("recording1",inputimage);
     cvWaitKey(0);
     OpenCVFrameRecorder recorder = new OpenCVFrameRecorder("output.avi",width,height);
      //recorder.setFrameRate(15.0);
        recorder.start();
         while(true){
       IplImage  inputimage1 = grabber.grab();
         cvShowImage("recording",inputimage1);
         cvWaitKey(2);
        recorder.record(inputimage);
         key=cvWaitKey(5);
         if(key==32){
        grabber.stop();
        grabber.release();
       recorder.stop();
       recorder.release();
       cvReleaseImage(inputimage.pointerByReference()) ;
        //cvReleaseImage(inputimage1.pointerByReference()) ;
          break;
         }
         }



    }
}

in both cases i am facing same problem and that problem is :-

# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x583c088d, pid=3448, tid=6096
#
# JRE version: 7.0
# Java VM: Java HotSpot(TM) Client VM (20.0-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C  [opencv_ffmpeg210.dll+0x10088d]
#
# An error report file with more information is saved as:
# C:\Users\anitha\Documents\NetBeansProjects7.0\recording\hs_err_pid3448.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
[NULL @ 0x4e3a500]non-existing PPS referenced
Compiler did not align stack variables. Libavcodec has been miscompiled
and may be very slow or crash. This is not a bug in libavcodec,
but in the compiler. You may try recompiling using gcc >= 4.2.
Do not report crashes to FFmpeg developers.
[h264 @ 0x4e3a500]number of reference frames exceeds max (probably ...
(more)