I have installed the plugin from github/joshdoe/gst-plugins-vision and using the Pylon gst.
I get error when I try to use the gstreamer plugin in python.
Any ideas? I have asked the question in github forum too, but since its more python related I figured I get a better chance of answer here.
CODE:
import cv2
import sys
import gi
from gi.repository import GObject, Gst
def open_cam(width, height):
# We want to set width and height here, otherwise we could just do:
# return cv2.VideoCapture(dev)
gst_str = ('pylonsrc config-file=acA2040.pfs! '
'queue ! '
'videoconvert ! appsink').format(width, height)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
def main():
print(cv2.__version__)
gi.require_version('Gst', '1.0')
Gst.debug_set_active(True)
Gst.debug_set_default_threshold(3)
cap = open_cam(2048, 2048)
if not cap.isOpened():
sys.exit("Failed to open camera!")
Gst.init(None)
if __name__== "__main__":
main()
ERROR:
sudo python3 main.py
main.py:4: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gst
4.2.0
0:00:00.441833101 18495 0x2d48440 pylonsrc gstpylonsrc.c:3675:gst_pylonsrc_load_configuration:<pylonsrc0> PylonC error: PylonC error #c2000001 'Could not load features from file.' (0xc2000001).
0:00:00.441950413 18495 0x2d48440 pylonsrc gstpylonsrc.c:3675:gst_pylonsrc_load_configuration:<pylonsrc0> PylonC error: Function 'PylonFeaturePersistenceLoad' failed in source file '../../../../../../../Pylon/PylonC/PylonC/PylonC.cpp' line #5187
Caused by an exception thrown from source file '../../../../../../Pylon/PylonUtility/FeaturePersistence.cpp' line #503.
The file could not opened for reading.
0:00:00.444235795 18495 0x2d48440 WARN basesrc gstbasesrc.c:3468:gst_base_src_start:<pylonsrc0> error: Failed to start
0:00:00.444327001 18495 0x2d48440 WARN basesrc gstbasesrc.c:3824:gst_base_src_activate_push:<pylonsrc0> Failed to start in push mode
0:00:00.444374673 18495 0x2d48440 WARN GST_PADS gstpad.c:1142:gst_pad_set_active:<pylonsrc0:src> Failed to activate pad
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1758) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module pylonsrc0 reported: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Failed to open camera!
Related
I am trying to package the following Python code into an executable file using PyInstaller:
import pandas as pd
import teradatasql
with teradatasql.connect(host='abcdxxx', user='abcdxxx', password='abcdxxx') as connect:
query = "SHOW TABLE AdventureWorksDW.DimAccount"
df = pd.read_sql(query, connect)
print(df)
When I run the .exe file, it gives me the error:
PyInstallerImportError: Failed to load dynlib/dll
'C:\\Users\\GAX~1.P\\AppData\\Local\\Temp\\_MEI153202\\teradatasql\\teradatasql.dll'.
Most likely this dynlib/dll was not found when the application was frozen.
[9924] Failed to execute script 'hello' due to unhandled exception!
I tried to make the following changes to the .spec file:
b = [
('C:\Users\Path_to_Python\Python\Python310\Lib\site-
packages\teradatasql\teradatasql.dll', '.\\teradatasql')
]
a = Analysis(['hello.py'],
pathex=[],
binaries=b,
datas=[] # , .....
)
But it doesn't resolve the problem. How to fix this?
We provide an article explaining how to include the Teradata SQL Driver for Python into an application packaged by PyInstaller:
https://support.teradata.com/community?id=community_blog&sys_id=c327eac51b1e9c103b00bbb1cd4bcb37
I'm working on a project which uses the speech_recognition module.
# Importing all the installed packages
import speech_recognition as sr
audio = sr.Recognizer
try:
with sr.Microphone() as source:
voice = audio.listen(source)
command = audio.recognize_google(voice)
print(command)
finally:
pass
I'm getting this error
I tried all the possible solutions and yet I get the same error again and again
I'm using the PyCharm editor.
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWitePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Traceback (most recent call last):
File "/home/rohan/Rocland_Python/Rocland/Rocland2.py", line 9, in <module>
command = audio.recognize_google(sound)
File "/home/rohan/Rocland_Python/Rocland/venv/lib/python3.9/site-
packages/speech_recognition/__init__.py", line 858, in recognize_google
if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0:
raise UnknownValueError()
speech_recognition.UnknownValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/rohan/Rocland_Python/Rocland/Rocland2.py", line 10, in <module>
except: command = command.lower()
NameError: name 'command' is not defined
Please help me. Thanks!
Here i have the speech recognition code snippet which i have used in one of my code , i hope it will work for yours also:
import speech_recognition as sr
rObject = sr.Recognizer()
audio = ''
with sr.Microphone() as source:
print("Speak...")
audio = rObject.listen(source, phrase_time_limit = 0)
print("Stop.")
try:
text = rObject.recognize_google(audio, language ='en-US')
print("You : "+ text)
except:
speak("Could not understand your audio...PLease try again !")
Try and checkout !
There is socket as well as command = command.lower()
I'm writing some tests for code that calls TensorFlow 2.0.1. This library imports the imp module, which triggers a deprecation warning when I run pytest. I'm trying to muffle this warning, but without success.
This is my testing module:
import pytest
import warnings
from fclib.models.dilated_cnn import create_dcnn_model
def test_create_dcnn_model():
with pytest.deprecated_call():
create_dcnn_model(seq_len=1, max_cat_id=[30, 120]) # calls tensorflow.keras code
The output from pytest test_dcnn.py is
[...]
======================================== FAILURES ========================================
_________________________________ test_create_dcnn_model _________________________________
def test_create_dcnn_model():
with pytest.deprecated_call():
> create_dcnn_model(seq_len=1, max_cat_id=[30, 120])
E Failed: DID NOT WARN. No warnings of type (<class 'DeprecationWarning'>, <class 'PendingDeprecationWarning'>) was emitted. The list of emitted warnings is: [].
fclib/tests/test_dcnn.py:11: Failed
---------------------------------- Captured stderr call ----------------------------------
2020-07-07 03:15:03.162833: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
2020-07-07 03:15:03.174538: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2095190000 Hz
2020-07-07 03:15:03.177318: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55ef3370ff20 executing computations on platform Host. Devices:
2020-07-07 03:15:03.177351: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version
==================================== warnings summary ====================================
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================ short test summary info =================================
FAILED fclib/tests/test_dcnn.py::test_create_dcnn_model - Failed: DID NOT WARN. No warn...
============================== 1 failed, 1 warning in 2.39s ==============================
So it complains that there was no warning, and yet the printed output says that there was a warning. What's happening here?
If I remove the with pytest.deprecated_call() line, I get:
def test_create_dcnn_model():
# with pytest.deprecated_call():
create_dcnn_model(seq_len=1, max_cat_id=[30, 120])
================================== test session starts ===================================
platform linux -- Python 3.6.10, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /data/forecasting/fclib
collected 1 item
fclib/tests/test_dcnn.py . [100%]
==================================== warnings summary ====================================
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
============================== 1 passed, 1 warning in 2.00s ==============================
So it passes, but the warning message is still present. How can I get rid of that message completely?
I cannot succeed to use xgboost package in Azure Machine Learning Studio interpreter. I am trying to import a model using xgboost that I trained in order to deploy it here. But It seems that my package is not set correctly because I cannot access to certain functions, particularly "xgboost.sklearn"
My model is of course using the xgboost.sklearn.something to do the classification
I tried to implement the package following two different methods :
from the tar.gz principle like here :
How can certain python libraries be imported in azure ML?Like the line import humanfriendly gives error
and also by clean package with the sandbox like there :
Uploading xgboost to azure machine learning: %1 is not a valid Win32 application\r\nProcess returned with non-zero exit code 1
import sys
import sklearn
import pandas as pd
import pickle
import xgboost
def azureml_main(dataframe1 = None, dataframe2 = None):
sys.path.insert(0,".\Script Bundle")
model = pickle.load(open(".\\Script
Bundle\\xgboost\\XGBv1.pkl",'rb'))
dataframe1, dftrue = filterdata(dataframe1)
## one processing step
pred = predictorV1(dataframe1,dftrue)
dataframe1['Y'] = pred
return dataframe1
Here is the error I get
Error 0085: The following error occurred during script evaluation, please view the output log for more information:
---------- Start of error message from Python interpreter ----------
Caught exception while executing function: Traceback (most recent call last):
File "C:\server\invokepy.py", line 199, in batch
odfs = mod.azureml_main(*idfs)
File "C:\temp\1098d8754a52467181a9509ed16de8ac.py", line 89, in azureml_main
model = pickle.load(open(".\\Script Bundle\\xgboost\\XGBv1.pkl", 'rb'))
ImportError: No module named 'xgboost.sklearn'
Process returned with non-zero exit code 1
---------- End of error message from Python interpreter ----------
Start time: UTC 05/22/2019 13:11:08
End time: UTC 05/22/2019 13:11:49
I just installed PyOpenGL and proceed practice with this tutorial. It starts with this simple code that creates a window:
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
window = 0 # glut window number
width, height = 500, 400 # window size
def draw(): # ondraw is called all the time
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen
glLoadIdentity() # reset position
# ToDo draw rectangle
glutSwapBuffers() # important for double buffering
# initialization
glutInit() # initialize glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height) # set window size
glutInitWindowPosition(0, 0) # set window position
window = glutCreateWindow("noobtuts.com") # create window with title
glutDisplayFunc(draw) # set draw function callback
glutIdleFunc(draw) # draw all the time
glutMainLoop()
But when I try to run it I get this set of errors:
An error ocurred while starting the kernel
libGL error: unable to load driver: nouveau_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: nouveau
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 43
Current serial number in output stream: 42
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 42
Current serial number in output stream: 43
Can someone guide me on what they mean or how to fix them?
There are some discussions on the internet about this issue, but I haven't found one with strong solution. I'm using Ubuntu 16 by the way. Thanks
It seems you have installed some proprietary drivers and after that things got broke. You should uninstall newly installed NVDIA driver and reinstall it. Then on main window go to search application and type additional drivers in that window select driver you installed.
If this doesn't help and you have not installed any additional drivers please type following command on terminal and see if you have this file
》》locate nouveau_dri.so
If it can't find install it and that should fix error.