justadudewhohacks / opencv-electron

Example for using opencv4nodejs with electron.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

opencv4nodejs with electron setup

komalpharate opened this issue · comments

Hi,
I need help on how to setup electron with opencv4nodejs.
Scenario:
I have some nodejs code using opencv4nodejs.
Now I want to add electron on top of that.
Can I know steps to do that?`
Thanks

Hi,

I am not sure if I get the question correctly. You should be able to do that, this repo gives you an example how to achieve that.

I have nodejs code with some modules like opencv4nodejs,fs,etc.
Now I want to do is,
use electron, create an html page, submit some info, and start my nodejs server(I have done this part but want to combine with my nodejs code now).
what are the changes or installations i need to do for that?
like
as mentioned on opencv4nodejs page
Add the following script to your package.json:

"electron-rebuild": "electron-rebuild -w opencv4nodejs"
Run the script:

$ npm run electron-rebuild
Require it in the application:

const cv = require('opencv4nodejs');

these are the only steps?

Yes these are the only steps. Well with electron you don't need a nodejs server, you can use the opencv4nodejs code directly in your electron application, like I did in this example.

If you want to keep your server which runs all the OpenCV related code then you don't need electron and can simply build a webpage, which interacts with your server via an API.

The point of using electron is to build desktop apps with html, css and js, similar to web development, but you are not limited to capabilities of a browser.

Actually I'm restricted to use electron only.
That is why.
One more doubt is ,
performance of opencv4nodejs gets affetcted by using electron?

There shouldn't be much of a difference in performance.

Hi,
I installed electron and done the implementation mentioned above.
I'm getting VideoCapture Issue:
Error: VideoCapture::New - failed to open capture at Timeout._onTimeout (...../liveStreamingController.js:59:24) at ontimeout (timers.js:386:14) at tryOnTimeout (timers.js:250:5) at Timer.listOnTimeout (timers.js:214:5)_

whereas,
the same code works without using electron pretty well.

Are you trying to open a webcam stream or a video file? In the latter case I would assume that the path to the file is simply wrong. Try to resolve the absolute path to your file using path.resolve.

videosource is rtsp url camera

I didn't get this::

In the latter case I would assume that the path to the file is simply wrong. Try to resolve the absolute path to your file using path.resolve.

Also..
I just want to mention..
Other node modules works fine with electron
Just opencv4nodejs doesn't seem to work with electron in my case.
And, the issue is with Videocapture function especially.

Hm I see. Well as I said in the other issue, I am not familar with rtsp. So opening the stream works from a nodejs server, but not from electron. Did you try to open the stream from a simple script/ not from a nodejs server?

I tried to open a VideoCapture to an example endpoint in electron and atleast it does not fail opening the capture.

Yes. I tried opening the stream using PythonOpenCV, CPP OpenCV, Gstreamer tools, ffmpeg, opencv4nodejs module, opencv-npm module.
All works fine.
Can I know the code you used to do open a VideoCapture?

I simply did call the constructor with the rtsp endpoint of an example video file: var cap = new cv.VideoCapture('rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov'). However reading from this example endpoint gave me empty images, so not sure if there is something wrong with the endpoint or if I did something wrong. Didn't find a useful endpoint for testing in the hurry. But it did not crash in the constructor while opening the capture as in your case.

@justadudewhohacks here's a test link, rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov my auto build opencv4nodejs cannot open this link but my VLC player can, could someone test this with var cap = new cv.VideoCapture('rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov') and let me know the results? thanks!

I too have the same issue when trying to open an RTSP stream through Video capture. Electron crashes. Any help in this regard will be very helpful.

Hi,
I couldnt solve the bug so had to remove electron.

May this help someone, https://questnr.com/post/brijeshlakkad_this-will-cover-things-one--4941681633657222177-48908

I had so many errors during this. I have made this blog so that anyone who has trouble will be able to solve it.