0

背景:

我正在做一个关于活动识别的人工智能项目,该项目需要我使用相机,并且必须使用 Java。它也必须是内置摄像头,因为我没有网络摄像头。当尝试使用JxCapture在 Java 中使用相机时,我不断收到下面列出的相同(谢天谢地不是那么神秘)错误。该错误似乎表明 Java,或者至少这个库和其他一些库无法获取我内置的相机源。我注意到这一点,因为JMF也有一个类似的问题,它无法检测到相机。

import com.teamdev.jxcapture.Codec;
import com.teamdev.jxcapture.EncodingParameters;
import com.teamdev.jxcapture.VideoCapture;
import com.teamdev.jxcapture.video.VideoFormat;
import com.teamdev.jxcapture.video.VideoSource;

import java.io.File;
import java.util.List;

/*
 * This example demonstrates the video capture from web camera.
 * <pre>
 * Platforms:           
 * Image source:        WebCamera
 * Output video format: 
 * Output file:         
 *
 * @author Serge Piletsky
 */
public class TemplateRun 
{
    public static void main(String[] args) throws Exception 
    {
        VideoCapture videoCapture = VideoCapture.create(VideoFormat.WMV); 
        // This is where things go south. 
        Thread.sleep(1000);
        ....
    }
}

研究:

我已经对这个问题进行了相当多的研究。有些人建议使用其中一种 Windows 操作系统、屏幕录制照相亭或 facetime 运行等变通方法,但没有人真正回答了这个问题本身。我还没有尝试过 OpenCV/JavaCV,因为我不想浪费另一个根深蒂固的时间来解决同样的问题。该代码还可以编译和运行(错误除外),甚至可以访问变量,因此库本身可以工作。Java/OSX 中的某些框架是否存在问题?有没有办法解决这个问题?有什么不错的现代作品吗?

482 [main] ERROR com.teamdev.jxcapture.VideoCapture - No compatible video capture modules found for running operating system.
availableVideoSources = [LionVideoDevice[Name='FaceTime HD Camera (Built-in)'; Enabled=false]]
webCamera = LionVideoDevice[Name='FaceTime HD Camera (Built-in)'; Enabled=false]
Exception in thread "main" java.lang.NullPointerException
at TemplateRun.main(TemplateRun.java:34)

硬件:

摄像头:V5.16 FaceTime 高清摄像头(内置)。

电脑:Macbook pro 2012 年中

操作系统:MAC OS Sierra 10.12.3

Java 版本:Java 8 更新,121

经过测试,似乎甚至 OpenCV/JavaCV 都无法从内置摄像头获取摄像头馈送。

4

1 回答 1

0

您正在尝试VideoCapture使用VideoFormat.WMV视频格式初始化类的实例。

JxCapture 在 MacOS 上不支持这种格式。您必须改用 VideoFormat.MP4:

VideoCapture videoCapture = VideoCapture.create(VideoFormat.MP4); 

VideoCapture或使用默认构造函数创建实例:

VideoCapture videoCapture = VideoCapture.create(); 
于 2017-03-13T11:54:06.357 回答