mesutpiskin / opencv-live-video-stream-over-http

:satellite: OpenCV is a sample project that is read from the video source (Camera, File System, NVR, DVR etc.) and displays the processed image via the http protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can you give a tutorial for opencv-live-video-stream-over-http?

pradeepm1610 opened this issue · comments

Can you give a tutorial for opencv-live-video-stream-over-http?

Because , I did not know to run this project.

help me !!!

Of course, I will update the read me document

Help!!!

  1. Update your opencv dll reference as readme file.
  2. You can open this project with an any java IDE (IntelliJ IDEA, NetBeans or Eclipse, etc.)
  3. Run this OpenCVCameraStream.java

How to increase the size of the webcam view ?

@PradeepSimba PradeepSimba The browser loading the page for a long time because streaming continues all the time.

If you want a resize an image then should use the video capture options.
Ex:

VideoCapture videoDevice = new VideoCapture(0);
videoDevice.set(propId, value);

for size
videoDevice.set(Videoio.CV_CAP_PROP_FRAME_WIDTH, 1024);

or resizer

Mat src  =  imread("imageName.jpg");
Mat resizeimage = new Mat();
Size scaleSize = new Size(300,200);
resize(src, resizeimage, scaleSize , 0, 0, INTER_AREA);

Omg, really "imageName.jpg", imageName.jpg your file image patg

...
if (!videoCapture.read(frame)) {
tmrVideoProcess.stop();
}
//procesed image
//Pls resize frame object, frame is your mat image
httpStreamService.imag = frame;
...

I done this . But , an error occurs .

`import org.opencv.core.;
import org.opencv.videoio.VideoCapture;
import javax.swing.
;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import static org.opencv.imgcodecs.Imgcodecs.imread;
import static org.opencv.imgproc.Imgproc.INTER_AREA;
import static org.opencv.imgproc.Imgproc.resize;

public class OpenCVCameraStream {

//region Properties
public static Mat frame = null;
private static HttpStreamServer httpStreamService;
static VideoCapture videoCapture;
static Timer tmrVideoProcess;
//endregion

//region Methods

public static void start() {


    videoCapture = new VideoCapture();
    videoCapture.open(0);
    if (!videoCapture.isOpened()) {
        return;
    }

    frame = new Mat();
    httpStreamService = new HttpStreamServer(frame);
    new Thread(httpStreamService).start();

    tmrVideoProcess = new Timer(100, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!videoCapture.read(frame)) {
                tmrVideoProcess.stop();
            }

            //procesed image
            Mat src  = frame ;
            Mat resizeimage = new Mat();
            Size scaleSize = new Size(500,500);
            resize(src, resizeimage, scaleSize , 0, 0, INTER_AREA);
            httpStreamService.imag = frame;



        }
    });
    tmrVideoProcess.start();
}

public static void main(String[] args) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);//Load opencv native library
    start();
}

//endregion

}
`

Error :
C:\Users\prade\.jdks\openjdk-14\bin\java.exe "-Djava.library.path=D:\install\open cv 3.1\opencv\build\java\x64;D:\install\open cv 3.1\opencv\build\java\x86" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.1\lib\idea_rt.jar=53901:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.1.1\bin" -Dfile.encoding=UTF-8 -classpath "D:\Github\opencv-live-video-stream-over-http\out\production\opencv-live-video-stream-over-http;D:\install\open cv 3.1\opencv\build\java\opencv-310.jar" OpenCVCameraStream go to http://localhost:8080 with browserOpenCV Error: Unknown error code -10 (Raw image encoder error: Empty JPEG image (DNL not supported)) in cv::BaseImageEncoder::throwOnEror, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\imgcodecs\src\grfmt_base.cpp, line 139 OpenCV Error: Unknown error code -10 (Raw image encoder error: Empty JPEG image (DNL not supported)) in cv::BaseImageEncoder::throwOnEror, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\imgcodecs\src\grfmt_base.cpp, line 139