簡體   English   中英

在OpenCV 3.2和Java中未檢測到IP攝像機

[英]Ip camera not detected in opencv 3.2 and Java

有誰能夠在Java的開放式簡歷中使用IP攝像機。 我使用了下面的代碼,該代碼對於網絡攝像頭效果很好。 但是當我嘗試使用網絡攝像機時卻無法正常工作

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
import javax.imageio.ImageIO;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
import org.opencv.objdetect.CascadeClassifier;
import org.opencv.videoio.VideoCapture;

import com.amazonaws.services.rekognition.model.Image;
import com.amazonaws.util.IOUtils;
import com.wso2telco.rnd.ui.DashBoard;
import com.wso2telco.rnd.ui.UI;

public class TestIPCamera {

private static final long SLEEP_TIME = 1000;
private static VideoCapture camera;
private static FaceComparer comparer;
private static UI ui;
private static DashBoard dashUi;

public static void main(String args[]) {

    comparer = new FaceComparer();

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    //nu.pattern.OpenCV.loadLocally();
    System.loadLibrary("opencv_java320");

    camera = new VideoCapture();
    camera.open("http://192.168.1.2:8080/video?video=x.mpjeg");
    System.out.println(camera.isOpened());
    while(!camera.isOpened()) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    if (!camera.isOpened()) {
        System.out.println("Camera Error");
    } else {
        System.out.println("Camera Ready");
        ui = new UI();
        dashUi = new DashBoard();

    }
    while(true){
        runImage();
    }
}

我嘗試了其他線程中給出的許多建議,但找不到該問題的具體答案。

在嘗試了不同的選項之后,最后我通過安裝Open CV 3.4.1版本解決了該問題。

當您安裝open cv時,它會顯示如下輸出。 在那里,您可以檢查FFMPEG:是否表示為NO。此配置停止使用代碼中的IP凸輪的代碼。 為了避免這種錯誤配置,您需要使用-D WITH_FFMPEG = ON ..安裝Open CV以解決此問題。

    --   OpenCV modules:
--     To be built:                 core flann hdf imgproc ml objdetect phase_unwrapping photo plot reg surface_matching video xphoto bgsegm dnn face freetype fuzzy img_hash imgcodecs shape videoio xobjdetect highgui superres ts bioinspired dpm features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco java optflow stitching python3
--     Disabled:                    world contrib_world
--     Disabled by dependency:      -
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev python2 viz cnn_3dobj cvv dnn_modern matlab sfm
-- 
--   GUI: 
--     QT:                          NO
--     GTK+ 3.x:                    YES (ver 3.20.9)
--     GThread :                    YES (ver 2.50.2)
--     GtkGlExt:                    NO
--     OpenGL support:              NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.25)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
--     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)
--     GDAL:                        NO
--     GDCM:                        NO
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  YES (ver 2.2.4)
--     FFMPEG:                      NO
--       avcodec:                    NO
--       avformat:                   NO
--       avutil:                     NO
--       swscale:                    NO
--       avresample:                 NO
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     Aravis SDK:                  NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    NO/YES
--     XIMEA:                       NO
--     Xine:                        NO
--     Intel Media SDK:             NO
--     gPhoto2:                     NO
-- 
--   Parallel framework:            TBB (ver 4.4 interface 9005)
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Use Intel IPP:               2017.0.2 [2017.0.2]
--                at:               /home/hao/opencv-3.3.0/build/3rdparty/ippicv/ippicv_lnx
--     Use Intel IPP IW:            prebuilt binaries (2017.0.2)
--     Use Intel IPP Async:         NO
--     Use VA:                      NO
--     Use Intel VA-API/OpenCL:     NO
--     Use Lapack:                  NO
--     Use Eigen:                   YES (ver 3.3.4)
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
--     Use OpenVX:                  NO
--     Use custom HAL:              NO
-- 
--   OpenCL:                        <Dynamic loading of OpenCL library>
--     Include path:                /home/hao/opencv-3.3.0/3rdparty/include/opencl/1.2
--     Use AMDFFT:                  NO
--     Use AMDBLAS:                 NO
-- 
--   Python 2:
--     Interpreter:                 (ver 2.7.12)
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.5.2)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.5m.so (ver 3.5.2+)
--     numpy:                       /usr/local/lib/python3.5/dist-packages/numpy/core/include (ver 1.12.0)
--     packages path:               lib/python3.5/dist-packages
-- 
--   Python (for build):            
-- 
--   Java:
--     ant:                         /usr/bin/ant (ver 1.9.7)
--     JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
--     Java wrappers:               YES
--     Java tests:                  YES
-- 
--   Matlab:                        Matlab not found or implicitly disabled
-- 
--   Documentation:
--     Doxygen:                     NO
-- 
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              YES
-- 
--   Install path:                  /usr/local
-- 
--   cvconfig.h is in:              /home/hao/opencv-3.3.0/build
-- 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM