gocv
gocv copied to clipboard
how to use gocv for ipc
I install gocv is ok,and use device 0 is ok,but I don't know how to use device is a IPC
Sorry what is an "IPC"? Can you please elaborate on what you are trying to do? Thanks.
I want use IP Camera,like "rtsp://admin:[email protected]"
GoCV already has streaming support, for example you can use the capwindow example to stream a URL like this:
$ go run ./cmd/capwindow/main.go http://187.157.229.132/mjpg/video.mjpg
Start reading device: http://187.157.229.132/mjpg/video.mjpg
Since OpenCV is normally built with ffmpeg and/or gstreamer, you should be able to to do something like this with the rtsp
protocol:
webcam, err := gocv.OpenVideoCapture("rtsp://admin:[email protected]")
Hope that helps!
I install gocv refer https://github.com/hybridgroup/gocv#windows, and when I use 0 for deviceID is ok,but use like 'rtsp://admin:[email protected]' is not ok. my code like:
package main
import (
"fmt"
"gocv.io/x/gocv"
)
func main() {
deviceID := "rtsp://admin:[email protected]"
//deviceID := "http://187.157.229.132/mjpg/video.mjpg"
webcam, err := gocv.OpenVideoCapture(deviceID)
if err != nil {
fmt.Printf("Error opening video capture device: %v\n", deviceID)
return
}
defer webcam.Close()
//webcam, _ := gocv.OpenVideoCapture(1)
window := gocv.NewWindow("Hello")
defer window.Close()
img := gocv.NewMat()
defer img.Close()
fmt.Printf("Start reading device: %v\n", deviceID)
for {
if ok := webcam.Read(&img); !ok {
fmt.Printf("Device closed: %v\n", deviceID)
return
}
if img.Empty() {
continue
}
window.IMShow(img)
if window.WaitKey(1) == 27 {
break
}
}
}
D:\GoCode\src\agent>main.exe rtsp://admin:1234@[email protected] Error opening video capture device: rtsp://admin:1234@[email protected]
when I run like "main.exe 0" is ok.
I think @DoubleChuang was suggesting you use this form of the command:
main.exe "rtsp://admin:1234@[email protected]"
However from the message displayed, I do not think that is your problem.
I wonder if you might need to make some change to the Windows firewall settings to allow the compiled program to open a port. You should investigate that, I have run into similar issues in the past.
@deadprogram I close the Windows firewall,but the command still not work
How did you build OpenCV?
@deadprogram I install gocv refer https://github.com/hybridgroup/gocv#windows
@yyf1986 The right uri maybe rtsp://<username>:<password>@<ip>:<port>/Streaming/channels/<stream_number>
, such as rtsp://admin:[email protected]:554/Streaming/channels/1/
-
<username>
and<password>
are the login authentication element -
<ip>
is the IP-address of camera -
<port>
is the port number of RTSP protocol, the default value is554
-
<stream_number>
is the channel number, if it is equal to1
, it indicates that the main stream is being captured; if it is equal to2
, it indicates that the secondary stream is being captured
@kuailehaibin when i use vlc to play with url "rtsp://admin:[email protected]" is ok,and I use python-opencv to captured is ok with url "rtsp://admin:[email protected]"
OK
when I use Ubuntu,the problem is solve.
I have the same problem. I think this maybe cause by ffmpeg? I search how to use OpenCV to play ffmpeg, and i find this need ffmpeg support. Maybe the "Windows Install" need to add build ffmpeg part?
@yyf1986 Are you unable to use it under the win10 environment and the error opening video capture device appears? This is also the case under win10, I do not know what the reason is.
@TangShuancheng yes, so I use Ubuntu to use it
I come across the same problem as yours,the problem is:
Error opening video capture device: rtsp://admin:[email protected]
Hi all,
I found the same problem in my dev env Fedora 35. Compilation went well and I can read my local camera as device 0. But having the same issue to capture the remote device with rtsp protocol. I can access the device using vlc and ffplay from the same environment.
I'm wondering if it might be a problem related to the OS and the ffmpeg
library ? I can see @yyf1986 on ubuntu got working and reading many other issues in this repo other users are running it without problems.
there is a way to verbose the ouput of gocv?
kind regards
Hi,
in my case, it was a problem related with the package FFMPEG of Fedora. At the moment of compiling openCV, it was not able to find FFMPEG in the system. I needed to compile FFMPEG with specific flags in order to be detected by the openCV compilation process.
This is the line to configure FFMPEG before installing openCV
sudo ./configure --pkgconfigdir=/usr/lib64/pkgconfig --incdir=/usr/include --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --disable-x86asm
Similar issue exists in the openCV repo itself.
The issue does not exist in other distros like ubuntu for example.
Hope it can help other people in future.