Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 corrupt input), discarding one Java Result: 1 BUILD SUCCESSFUL (total time: 2 seconds)

click to hide/show revision 2
No.2 Revision

updated 2013-02-21 04:44:20 -0600

berak gravatar image

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"

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

using namespace std;

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;

}

0; }

2.) in Java language written

import name.audet.samuel.javacv.OpenCVFrameRecorder;
import  com.sun.jna.;
com.sun.jna.*;
import  name.audet.samuel.javacv.jna.;
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.;
name.audet.samuel.javacv.jna.cv.v21.*;
import static name.audet.samuel.javacv.jna.cvaux.v21.;
name.audet.samuel.javacv.jna.cvaux.v21.*;
import static name.audet.samuel.javacv.jna.cxcore.v21.;
name.audet.samuel.javacv.jna.cxcore.v21.*;
import static name.audet.samuel.javacv.jna.highgui.;
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:

#

Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x583c088d, pid=3448, tid=6096

#

tid=6096 # # JRE version: 7.0

7.0 # Java VM: Java HotSpot(TM) Client VM (20.0-b01 mixed mode, sharing windows-x86 )

) # Problematic frame:

frame: # C [opencv_ffmpeg210.dll+0x10088d]

#

[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

#

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

visit: # http://java.sun.com/webapps/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code.

code. # See problematic frame for where to report the bug.

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 corrupt input), discarding one Java Result: 1 BUILD SUCCESSFUL (total time: 2 seconds)

seconds)