我不能記錄網絡攝像頭視頻(即捕獲和保存 .AVI或.MP4文件)使用JavaCV/OpenCV的/ FFMPEG , 我究竟做錯了什麼?Java的CV 1.0網絡攝像頭視頻拍攝:框架不能轉換到IplImage的
版使用(全部64位)
運7,NetBeans8.0.2,jdk1.7.0_10,JavaCV 1.0,OpenCV的3.0.0,FFMPEG-2.1.1-Win64的共用。
我的系統變量設置爲
C:\ Program Files文件\的Java \ jdk1.7.0_10;的%SystemRoot%\ SYSTEM32;的%SystemRoot%;%SYSTEMROOT%\ SYSTEM32 \ Wbem;%SYSTEMROOT%\ System32 \ WindowsPowerShell \ v1.0 \; C:\ Program Files \ Intel \ WiFi \ bin \; C:\ Program Files \ Common Files \ Intel \ WirelessCommon \; C:\ Program Files(x86) \ Intel \ OpenCL SDK \ 2.0 \ bin \ x86; C:\ Program Files(x86)\ Intel \ OpenCL SDK \ 2.0 \ bin \ x64; C:\ Program Files(x86)\ MySQL \ MySQL Fabric 1.5.4 & MySQL Utilities 1.5.4 1.5 \; C:\ Program Files(x86)\ MySQL \ MySQL Fabric 1.5.4 & MySQL Utilities 1.5.4 1.5 \ PHP的學說擴展\; C:\ OpenCV的\建設\ 64 \ VC11 \ BIN; C:\ ffmpeg的\ BIN
下載和設置路徑變量後,我加入的jar文件到NetBeans項目
C: \ opencv \ build \ java \ opencv-300.jar C:\ javacv-1.0-bin \ javacv-bin \ videoinput.jar C:\ javacv-1.0-bin \ javacv-bin \ videoinput-windows-x86_64.jar C:\ javacv-1.0-bin \ javacv-bin \ videoinput-windows-x86.jar C:\ javacv-1.0-bin \ javacv-bin \ opencv.jar C:\ javacv-1.0-bin \ javacv-bin \ opencv-windows-x86_64.jar C:\ javacv-1.0-bin \ javacv-bin \ opencv-windows-x86.jar C:\ javacv-1.0- bin \ javacv-bin \ libfreenect.jar C:\ javacv-1.0-bin \ javacv-bin \ libfreenect-windows-x86_64.jar C:\ javacv-1.0-bin \ javacv-bin \ libfreenect-windows-x86。 jar C:\ javacv-1.0-bin \ javacv-bin \ libdc1394.jar C:\ javacv-1.0-bin \ javacv-bin \ junit.jar C:\ javacv-1.0-bin \ javacv-bin \ javacv .jar C:\ javacv-1.0-bin \ javacv-bin \ javacpp.jar C:\ javacv-1.0-bin \ javacv-bin \ hamcrest-core.jar C:\ javacv-1.0-bin \ javacv- bin \ flycapture.jar C:\ javacv-1.0-bin \ javacv-bin \ flycapture-windows-x86_64.jar C:\ javacv-1.0-bin \ javacv-bin \ fly capture-windows-x86.jar C:\ javacv-1.0-bin \ javacv-bin \ flandmark.jar C:\ javacv-1.0-bin \ javacv-bin \ flandmark-windows-x86_64.jar C:\ javacv -1.0-bin \ javacv-bin \ flandmark-windows-x86.jar C:\ javacv-1.0-bin \ javacv-bin \ ffmpeg.jar C:\ javacv-1.0-bin \ javacv-bin \ ffmpeg-windows -x86_64.jar C:\ javacv-1.0-bin \ javacv-bin \ ffmpeg-windows-x86.jar C:\ javacv-1.0-bin \ javacv-bin \ artoolkitplus.jar C:\ javacv-1.0- bin \ javacv-bin \ artoolkitplus-windows-x86_64.jar C:\ javacv-1.0-bin \ javacv-bin \ artoolkitplus-windows-x86。罐子
問題1:
第一個程序來捕獲攝像頭的視頻(顯示並保存到output.avi文件)是如下面給出的。
它顯示攝像頭並創建output.avi。但終止程序,當我打開文件output.avi媒體播放器不顯示任何東西:)後
它不工作
import java.io.File;
import java.net.URL;
import org.bytedeco.javacv.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.indexer.*;
import static org.bytedeco.javacpp.opencv_core.*;
import static org.bytedeco.javacpp.opencv_imgproc.*;
import static org.bytedeco.javacpp.opencv_calib3d.*;
import static org.bytedeco.javacpp.opencv_objdetect.*;
public class JCVdemo3 {
public static void main(String[] args) throws Exception {
// Preload the opencv_objdetect module to work around a known bug.
Loader.load(opencv_objdetect.class);
// The available FrameGrabber classes include OpenCVFrameGrabber (opencv_videoio),
// DC1394FrameGrabber, FlyCaptureFrameGrabber, OpenKinectFrameGrabber,
// PS3EyeFrameGrabber, VideoInputFrameGrabber, and FFmpegFrameGrabber.
FrameGrabber grabber = FrameGrabber.createDefault(0);
grabber.start();
// CanvasFrame, FrameGrabber, and FrameRecorder use Frame objects to communicate image data.
// We need a FrameConverter to interface with other APIs (Android, Java 2D, or OpenCV).
OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage();
IplImage grabbedImage = converter.convert(grabber.grab());
int width = grabbedImage.width();
int height = grabbedImage.height();
FrameRecorder recorder = FrameRecorder.createDefault("output.avi", width, height);
recorder.start();
CanvasFrame frame = new CanvasFrame("Some Title");
while (frame.isVisible() && (grabbedImage = converter.convert(grabber.grab())) != null) {
// cvWarpPerspective(grabbedImage, rotatedImage, randomR);
Frame rotatedFrame = converter.convert(grabbedImage);
//opencv_core.IplImage grabbedImage = grabber.grab();
frame.showImage(rotatedFrame);
recorder.record(rotatedFrame);
}
frame.dispose();
recorder.stop();
grabber.stop();
}
}
問題2:當我運行下面的代碼
opencv_core.IplImage grabbedImage = grabber.grab();
不兼容的類型:幀不能被轉換爲的IplImage出現
0消息問題是:我做錯了什麼?
我無法錄製任何類型的視頻;不管我使用的是什麼版本的JavaCV/OPenCv。
請告訴我一個工作示例,以便從網絡攝像頭錄製視頻,以及工作的JavaCV/OpenCV/FFmpeg兼容版本。