本文介绍了如何将图像用javacv转换成Android的视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在SD卡图像转换成视频在android.After许多搜索,我发现有可能在javacv.when我尽量简单javacv样品中纯java中,把它的时候我变成机器人在我eclipse.but工作完美中,相同的样品中不android.i下载运行,并添加在myproject->库/ armeabi folder.my项目不显示任何errors.but错误运行期间occcured

我与此类尝试,

 包com.example.ndkfoo_sample;

进口静电com.google code.javacv.cpp.opencv_core.cvReleaseImage;
进口静电com.google code.javacv.cpp.opencv_highgui.cvLoadImage;
进口静电com.google code.javacv.cpp.opencv_highgui.cvShowImage;
引入静态com.google code.javacv.cpp.opencv_highgui.cvWaitKey;
引入静态com.google code.javacv.cpp.opencv_imgproc.CV_GAUSSIAN;
进口静电com.google code.javacv.cpp.opencv_imgproc.cvSmooth;

进口com.google code.javacv.cpp.opencv_core.IplImage;

进口android.os.Bundle;
进口android.app.Activity;
进口android.view.Menu;

公共类MainActivity延伸活动{

// @覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);
IplImage的IMG = cvLoadImage(helloworld.jpg);

    cvShowImage(到/ mnt / SD卡/ HelloWorld的,IMG);
    cvSmooth(IMG,IMG,CV_GAUSSIAN,13);
    cvShowImage(模糊映像,IMG);
    cvWaitKey();
    cvReleaseImage(IMG);
}

@覆盖
公共布尔onCreateOptionsMenu(功能菜单){
    。getMenuInflater()膨胀(R.menu.activity_main,菜单);
    返回true;
}
}
 

我的错误是一样的,

  OpenCV的错误未指定的错误。
 

我的问题是如何整合的OpenCV / javacv在android.is有任何步骤或教程?

感谢

解决方案

使用以下行。

**

  opencv_core.IplImage IMG = cvLoadImage(/ SD卡/文件夹/ img1.jpg);
FFmpegFrameRecorder记录=新FFmpegFrameRecorder(/ SD卡/文件夹/ test.mpeg,200150);

    尝试 {
       recorder.set codeCID(codeC_ID_MPEG1VIDEO);
       recorder.setFrameRate(30);
       recorder.setPixelFormat(PIX_FMT_YUV420P);
       recorder.start();

       的for(int i = 0; I< 100;我++)
       {
          recorder.record(图像[X]);
       }
       recorder.stop();
    }
    赶上(例外五){
       e.printStackTrace();
    }
 

**这是由javacv库支持。有关详细信息,阅读Javacv Readme.txt文件。希望这会帮助你。

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,

解决方案

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.

这篇关于如何将图像用javacv转换成Android的视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:53