Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pradeepm1610 opened this issue May 28, 2020 · 7 comments
Closed

Comments

@pradeepm1610
Copy link

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

Because , I did not know to run this project.

help me !!!

@mesutpiskin
Copy link
Owner

Of course, I will update the read me document

@pradeepm1610
Copy link
Author

Help!!!

@mesutpiskin
Copy link
Owner

  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

@pradeepm1610
Copy link
Author

How to increase the size of the webcam view ?

@mesutpiskin
Copy link
Owner

@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);

@mesutpiskin
Copy link
Owner

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;
...

@pradeepm1610
Copy link
Author

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

@ghost ghost mentioned this issue May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants