Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
669 views
in Technique[技术] by (71.8m points)

how to convert images into video in android using javacv?

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,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...