简体   繁体   English

在OpenCV 3.2和Java中未检测到IP摄像机

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

Have anyone able to use ip camera with open cv with Java. 有谁能够在Java的开放式简历中使用IP摄像机。 I used the below code which was working fine for the web camera. 我使用了下面的代码,该代码对于网络摄像头效果很好。 But when i Tried to use a ip cam it was not working 但是当我尝试使用网络摄像机时却无法正常工作

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();
    }
}

I tried many suggestions given in other threads but couldn't find a concrete answer for the issue. 我尝试了其他线程中给出的许多建议,但找不到该问题的具体答案。

After Trying different options Finally i resolved the issue by installing the Open CV 3.4.1 version the issue got resolved. 在尝试了不同的选项之后,最后我通过安装Open CV 3.4.1版本解决了该问题。

When you install open cv it shows an output like below. 当您安装open cv时,它会显示如下输出。 there you can check that FFMPEG: is stated as NO This configuration stops the code of using the IP cams in the code. 在那里,您可以检查FFMPEG:是否表示为NO。此配置停止使用代码中的IP凸轮的代码。 To avoid this mis configuration you need install Open CV with the -D WITH_FFMPEG=ON .. to solve this problem 为了避免这种错误配置,您需要使用-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