I used Pytesseract module for OCR. It seems slow process. So I followed
Pytesseract is too slow. How can I make it process images faster? .
I used code mentioned in https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/tesseract-ocr/xvTFjYCDRQU/rCEwjZL3BQAJ . But getting error
!strcmp(locale, "C"):Error:Assert failed:in file baseapi.cpp, line 201
Segmentation fault (core dumped),
Then i check some post and get reference to add in my code locale.setlocale(locale.LC_ALL, "C").
So after added this in my code I got another error
Traceback (most recent call last):
File "master_doc_test3.py", line 107, in <module>
tess = Tesseract()
File "master_doc_test3.py", line 67, in __init__
if self._lib.TessBaseAPIInit3(self._api, datapath, language):
ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type`
Can anyone give idea about this error? OR If anyone have idea about best way to make OCR in fastest way using python.
You should try to convert to bytes every parameter you pass to ctypes lib calls:
self._lib.TessBaseAPIInit3(self._api, datapath, language)
Something like this is working for me:
self._lib.TessBaseAPIInit3(self._api, bytes(datapath, encoding='utf-8'), bytes(language, encoding='utf-8'))
I have got the clue here.
Please, take into consideration that the code you are using needs more fine tuning in other lib calls as the next ones:
tess.set_variable(bytes("tessedit_pageseg_mode", encoding='utf-8'), bytes(str(frame_piece.psm), encoding='utf-8'))
tess.set_variable(bytes("preserve_interword_spaces", encoding='utf-8'), bytes(str(1), encoding='utf-8'))
Related
I have downloaded the procedure I have on my laptop on my lab’s computer from my Google Drive, and I had to take some edits to test it.In order to this, I have to add some text components with some specific code. However when I tried to add and use the $ symbol to read the text I would like to refer to, I get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/psychopy/app/builder/dialogs/paramCtrls.py", line 31, in validate
validate(self, self.valType)
File "/usr/local/lib/python3.8/dist-packages/psychopy/app/builder/dialogs/paramCtrls.py", line 550, in validate
val = str(obj.GetValue())
RecursionError: maximum recursion depth exceeded while calling a Python object
Could anyone possibly have some good piece of advice or workaround to manage with it?
Thanks
What version of PsychoPy are you using? I believe this was fixed in Feb 2022 so probably updating to a new version of psychopy should fix it for you.
https://github.com/psychopy/psychopy/pull/4569
I am testing out python opencv (cv2) to detect multiple images using openvino DNN models.
My code for first detection:
import cv2
dog=cv2.imread("dog.jfif")
cat=cv2.imread("cat.jfif")
net=cv2.dnn.readNet("ssd_mobilenetv2_fp16_scale2.xml","ssd_mobilenetv2_fp16_scale2.bin")
blob=cv2.dnn.blobFromImage(dog)
net.setInput(blob)
out=net.forward()
Until here, no error is shown and print (out) shows that the "dog" detection is successful.
But then when i continue the next detection of "cat" image by adding the next few lines:
blob=cv2.dnn.blobFromImage(cat)
net.setInput(blob)
out=net.forward()
And I get:
>>> out = net.forward()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.3.0-openvino) ../opencv/modules/dnn/src/ie_ngraph.cpp:522: error: (-215:Assertion failed) !isInitialized() in function 'initPlugin'
Why does this error occur? What is the correct way to do for the second detection?
Probably you can try to run the dog and cat detection separately because the program might confuse of those 2 inputs that came at the same time during the implementation of blob.
Another workaround is, if you still want them to work simultaneously, name the blob differently such as:
For dog:
blob1=cv2.dnn.blobFromImage(dog)
net.setInput(blob1)
For cat
blob2=cv2.dnn.blobFromImage(cat)
net.setInput(blob2)
so that the function net.setInput(blob) doesn't get confuse on which input it should refer to.
Thanks!
current_call.transfer("sip:1001#xx.xx.xx.xx") is working python2.7 How ever it is not working in python3.7
below is the error
Original exception was:
Traceback (most recent call last):
File "trycall.py", line 151, in <module>
current_call.transfer("sip:1001#xx.xx.xx.xx")
File "/usr/local/lib/python3.7/dist-packages/pjsua.py", line 1734, in transfer
Lib._create_msg_data(hdr_list))
SystemError: <built-in function call_xfer> returned NULL without setting an error
I am using this branch of PJSIP: Link
for PJSUA implementation with Python 3.6 and have encountered same problem with transfer.
Removing this check from function py_pjsua_call_xfer (pjproject/pjsip-apps/src/python/_pjsua.c) solved my problem:
if (!PyBytes_Check(pDstUri))
return NULL;
This check always returns NULL in all my tests. I was not able to solved this with Python. Removing code mentioned above solved the issue and for now it haven't created any new problems. I have tested this modification with Asterisk and 3 SIP endpoints and transfer was correctly processed.
(note: I am not a C/C++ programmer, so I cannot provide detail explenation why this code doesn't work. This approach is based on trial and error.)
I am trying to dynamically create a class for an owlready2 ontology. The documentation suggests the following line of code:
NewClass = types.new_class("NewClassName", (SuperClass,), kwds = { "namespace" : my_ontology })
In my case this equals
types.new_class("NewClassName", (onto["ParentClass"],), kwds={'namespace' : onto})
However, when I run the above code, I get the following exception:
Traceback (most recent call last):
(onto[object.get('owl_dataProperty_parent')],), kwds={'namespace' : onto})
File "/usr/lib/python3.6/types.py", line 62, in new_class
return meta(name, bases, ns, **kwds)
TypeError: __new__() got an unexpected keyword argument 'namespace
I have no idea what went wrong there and after hours of debugging I am still clueless.
I am using Python 3.6.6 and version 0.11 of owlready2
I figured out that the "namespace" attribute is not needed at all. So the following works just fine:
types.new_class("NewClassName", (onto["ParentClass"],))
Even though this does not solve the overall issue, it answered my question.
Additionally, it seams like this is the way to do it in general, cf.owlready forum. So maybe it is time to update the documentation.
I am running gridSearchCV in parallel with n_jobs > 1, but randomly hit the following crash in joblib:
TypeError: Cannot create a consistent method resolution
order (MRO) for bases JoblibException, Exception
Here is the complete stack trace:
Traceback (most recent call last):
File "example_sklearn.py", line 92, in <module>
main()
File "example_sklearn.py", line 76, in main
).fit(X_train, y_train)
File "/usr/local/lib/python2.7/dist-packages/sklearn/grid_search.py",
line 372, in fit for clf_params in grid for train, test in cv)
File "/usr/local/lib/python2.7/dist-packages/sklearn/externals/joblib/parallel.py",
line 516, in __call__self.retrieve()
File "/usr/local/lib/python2.7/dist-packages/sklearn/externals/joblib/parallel.py",
line 448, in retrieve exception_type = _mk_exception(exception.etype)[0]
File "/usr/local/lib/python2.7/dist-packages/sklearn/externals/joblib/my_exceptions.py",
line 61, in _mk_exception__str__=JoblibException.__str__),
TypeError: Cannot create a consistent method resolution
order (MRO) for bases JoblibException, Exception
Any pointers on what this really is, and how I can debug this. Is this a known issue with sklearn
I had the exact same exception, exactly while using the GridSearchCV.
If you look at the exception, it is complaining about not being able to understand how exactly it should choose between two parent classes JoblibException and Exception. This is a bug in the joblib package, that the inheritance is improper.
But other than than, there exist another problem, which is the source of the exception itself. It's getting an exception while retrieve()ing, and while passing the exception, you get the error.
The second problem (which is the source of the exception), seems to be fixed in later versions of joblib. But scikit-learn is still using an old version (I will submit a pull request with the changed file soon).
A temporary workaround would be to install your own version of joblib using
easy_install joblib
and then go to the sklearn/exterlan folder, remove/rename the joblib folder, and create a symbolic link to your own joblib using:
ln -s /path/to/joblib joblib
EDIT: Seems somebody has had already fixed the problem. My version was also old.