7

i want to convert the sdcard images into video in android.After many of searching i found it is possible in javacv.when i try simple javacv sample in pure java,its working perfectly in my eclipse.but when i turn into android,the same sample does not run in android.i download and add all the .jar files and .so files in myproject->libs/armeabi folder.my project doesn't show any errors.but error occcured during the runtime.

i try with this class,

package com.example.ndkfoo_sample; import static com.googlecode.javacv.cpp.opencv_core.cvReleaseImage; import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage; import static com.googlecode.javacv.cpp.opencv_highgui.cvShowImage; import static com.googlecode.javacv.cpp.opencv_highgui.cvWaitKey; import static com.googlecode.javacv.cpp.opencv_imgproc.CV_GAUSSIAN; import static com.googlecode.javacv.cpp.opencv_imgproc.cvSmooth; import com.googlecode.javacv.cpp.opencv_core.IplImage; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { // @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); IplImage img=cvLoadImage("helloworld.jpg"); cvShowImage("/mnt/sdcard/helloworld",img); cvSmooth(img,img,CV_GAUSSIAN,13); cvShowImage("Blur-Image",img); cvWaitKey(); cvReleaseImage(img); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } 

My error is like as,

 opencv error unspecified error. 

My question is how to integrate opencv/javacv in android.is there any steps or tutorials.?

thanks,

2
  • can you please put the code for more guidance because i have same problem occure. Commented Jul 7, 2015 at 12:37
  • Can you please me list me the jars that you used in your project for javacv ? I am using android studio so everything is new to me. Commented Oct 12, 2015 at 8:30

1 Answer 1

9

Use the following lines .

**

opencv_core.IplImage img = cvLoadImage("/sdcard/folder/img1.jpg"); FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("/sdcard/folder/test.mpeg",200,150); try { recorder.setCodecID( CODEC_ID_MPEG1VIDEO); recorder.setFrameRate(30); recorder.setPixelFormat( PIX_FMT_YUV420P); recorder.start(); for (int i=0;i<100;i++) { recorder.record(image[x]); } recorder.stop(); } catch (Exception e){ e.printStackTrace(); } 

** This is supported by javacv library. for more details read Javacv Readme.txt file. Hope this will help you.

Sign up to request clarification or add additional context in comments.

16 Comments

did u got video from images without green color?
hi tried your answer.i am getting error in this line,recorder.setCodecID(CODEC_ID_MPEG1VIDEO); error:CODEC_ID_MPEG1VIDEO can't be resolved to a variable.
for that you need to use javacv.jar and javacpp.jar files in your lib folder.. import from that jar files..
Experiment with other codecs: CODEC_ID_MPEG4 followed by recorder.setFormat("mp4");
@karlphillip yeah i have checked with both of them also.. it will create a file but i didn't got a perfect video file..
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.