I am trying to capture from a streaming IP cam with username and password and port like so:vs = cv2.VideoCapture('http://user:password#ipadress:port/video.cgi?.mjpg')
but when I run the script I get this error in the cmd output:
[ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (116) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): http://user:password#ipadress:port/video.cgi?.mjpg in function 'cv::icvExtractPattern'
things I tried:
-installing FFmpeg and directing it to the environment path
-trying different ports
-switching between HTTP and RTSP
obviously, I'm new. thank you.
Related
I use mcpi: https://github.com/AdventuresInMinecraft/AdventuresInMinecraft-Linux
Starting the local server.
After, run program:
import mcpi.minecraft as minecraft
mc = minecraft.Minecraft.create()
mc.postToChat("Hello Minecraft World")
I am facing the below error:
Traceback (most recent call last):
File "/home/home/AdventuresInMinecraft/MyAdventures/HelloMinecraftWorld.py", line 2, in mc = minecraft.Minecraft.create()
File "/home/home/.local/lib/python3.6/site-packages/mcpi/minecraft.py", line 376, in create return Minecraft(Connection(address, port))
File "/home/home/.local/lib/python3.6/site-packages/mcpi/connection.py", line 17, in init self.socket.connect((address, port))
ConnectionRefusedError: [Errno 111] Connection refused
A ConnectionRefusedError means that the address + port combination was unable to be secured for this particular Minecraft server and thus raised an exception. This could be because some other application is already using the port of interest, the port is unavailable because of the OS, or a handful of other networking configuration mishaps.
But perhaps a better series of questions to ask yourself is:
What is the default address and port that minecraft.Minecraft.create() will attempt to launch / listen at?
Do I have access to that server (address + port)?
If I do have access, are there any security issues (AKA Firewall)?
This post has already addressed the root issue of your question, and I hope it gives you a good start at understanding the foundation of your problem.
Notice how their question mentions s.connect((host,port)) and your stack trace has self.socket.connect((address, port)) Looks like the same thing to me!
Some more reading:
- localhost
- check if port is in use
I encountered the same issue. I looked into the code of mcpi and found that the default port is 4711. However, a Minecraft Server's default port is 25565. All you need to do is add 2 parameters on the create() function. Code(Python):
mc = minecraft.Minecraft.create(address="127.0.0.1", port=25565)
btw change "address" in the code to the host of the server (only if you modified the "server.properties" file).
Also, ConnectionRefusedError doesn't mean that it's not secured, I believe it means that either the server is not online, it doesn't exist, or the server refused it for some reason.
EDIT:
Oops sorry I just found out that mcpi actually connects to the RaspberryJam plugin which is hosted on another IP and port. The plugin runs on port 4711. So mcpi has the right port.
So check if you have the RaspberryJam plugin installed. If not, download it from
https://www.spigotmc.org/resources/raspberryjuice.22724/
And put the .jar file inside the plugins folder in your server directory.
I writing app in python that uses pocketsphinx and pjsip
I use pocketsphinx keyword search to wakeup the app and pjsip as phone
the problem is when I try call the "call" function and after that returning to listen to the keyword and then I get an error message from pjsip that he cannot open the sound device:
pjsua_aud.c ..Opening sound device (speaker + mic) PCM#16000/1/20ms
alsa_dev.c ...ALSA lib pcm_hw.c:1557:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0c' failed (-16): Device or resource busy
pjsua_aud.c ..Unable to open sound device: Unknown error from audio driver (PJMEDIA_EAUD_SYSERR) [status=420002]
operation=make_call(), error=Unknown error from audio driver (PJMEDIA_EAUD_SYSERR)
this error only happens when i try to return to the keyword function that uses alsaaudio
so my question will be how I can open the same audio device with pjsip and alsaaudio?
I am working on a Python script to search for bluetooth devices and connect them using RFCOMM. This devices has Passkey/Password. I am using PyBlueZ and, as far as I know, this library cannot handle Passkey/Password connections (Python PyBluez connecting to passkey protected device).
I am able to discover the devices and retrieve their names and addresses:
nearby_devices = bluetooth.discover_devices(duration=4,lookup_names=True,
flush_cache=True, lookup_class=False)
But if tried to connect to a specific device using:
s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
s.connect((addr,port))
I get an error 'Device or resource busy (16)'.
I tried some bash commands using the hcitool and bluetooth-agent, but I need to do the connection programmatically. I was able to connect to my device using the steps described here: How to pair a bluetooth device from command line on Linux.
I want to ask if someone has connected to a bluetooth device with Passkey/Password using Python. I am thinking about to use the bash commands in Python using subprocess.call(), but I am not sure if it is a good idea.
Thanks for any help.
Finally I am able to connect to a device using PyBlueZ. I hope this answer will help others in the future. I tried the following:
First, import the modules and discover the devices.
import bluetooth, subprocess
nearby_devices = bluetooth.discover_devices(duration=4,lookup_names=True,
flush_cache=True, lookup_class=False)
When you discover the device you want to connect, you need to know port, the address and passkey. With that information do the next:
name = name # Device name
addr = addr # Device Address
port = 1 # RFCOMM port
passkey = "1111" # passkey of the device you want to connect
# kill any "bluetooth-agent" process that is already running
subprocess.call("kill -9 `pidof bluetooth-agent`",shell=True)
# Start a new "bluetooth-agent" process where XXXX is the passkey
status = subprocess.call("bluetooth-agent " + passkey + " &",shell=True)
# Now, connect in the same way as always with PyBlueZ
try:
s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
s.connect((addr,port))
except bluetooth.btcommon.BluetoothError as err:
# Error handler
pass
Now, you are connected!! You can use your socket for the task you need:
s.recv(1024) # Buffer size
s.send("Hello World!")
Official PyBlueZ documentation is available here
Is there a way to connect two phones via Bluetooth , the script should be running on a Linux host. Any suggestions of using pybluez or any other APIs?
I have seen some examples where a Linux host is used as Client and is connect a phone (which is a server), but here I'm want to use Linux host as just a device to run the script and make two phones connect via Bluetooth.
I am trying to send a file from my PC to many servers to a specific folder in the server directory using one script, for keeping things simple, I am trying in the beginning to send one file to one server instead of many.
I am already connected to a server using a key for authentication, so I do not need to use any login info in my code. I have used the following:
import pysftp as sftp
def Filetransfer():
try:
s = sftp.Connection(host='IP address')# this is where the server ip address is inserted
remotepath='/xx/yy/file.txt'# where my file will be transferred to
localpath='C:/Users/David/Desktop/file.txt'# this is the file location in my PC
s.put(localpath,remotepath)
s.close()
except Exception, e:
print str(e)
Filetransfer()
I get the following Exception:
AttributeError: "'Connection' object has no attribute '_transport_live'" in <bound method Connection.__del__ of <pysftp.Connection object at 0x0000000002E1F3C8>>
I have tried to insert the server port beside the IP address, it did not help as I get the same error.
Use this
sftp.Connection(host="your_host", port="your_port", username="user_name", private_key="private_key")
if you're still having problems change private_key to password
check out the documentation
http://pysftp.readthedocs.org/en/release_0.2.8/pysftp.html
I'm trying to get the service name of port number 1521 using socket package.
This is the code I'm trying to execute in shell
import socket
portname = socket.getservbyport(1521)
print portname
The error I'm getting is as below
portname = socket.getservbyport(i)
socket.error: port/proto not found
If I'm using any other port such as 22,80,1433,3306 their isn't any problem in retrieving the port/service name.
I've tried similar code on two other Linux Machine but their isn't any response.