I'm using a Raspicam with the SimpleCV framework, when I work on the SimpleCV Shell everything work well. When i work with Python script I have some problems.
When I launch a python script like this:
from SimpleCV import *
cam = Camera(0)
screen = cam.getImage().rotate(180)
screen.save("Code/SimpleCV/SimpleCV/app/screen2.jpg")
everything work.
But when i set the format 1280X1024 with a code like this:
from SimpleCV import *
cam = Camera(0, {"width":1280, "height":1024})
screen = cam.getImage().rotate(180)
screen.save("Code/SimpleCV/SimpleCV/app/screen2.jpg")
I receive this error:
ERROR:
Traceback (most recent call last):
File "Code/SimpleCV/SimpleCV/app/getimm.py", line 5, in <module>
cam.getImage().save("Code/SimpleCV/SimpleCV/app/screen2.jpg")
File "/home/pi/Code/SimpleCV/SimpleCV/Camera.py", line 618, in getImage
cv.GrabFrame(self.capture)
TypeError: Expected CvCapture for argument 'capture'
Thanks
Related
I encountered a problem with blender when I try to start it with an external Python script ("--python import.py"), which should import a blend file and tries to manipulate the rotation and position of an object which is in the blend file.
What do I want to do?
I want to start blender with an external python script to import an unknown number of ".blend"-Files an set the position and rotation of that object in the file.
So my python script "import.py" looks like this:
import bpy
import os
import math
bpy.ops.wm.append(
filepath=os.path.join('H:\\Python\\blender\\test2.blend', 'Object', 'Gear'),
directory=os.path.join('H:\\Python\\blender\\test2.blend', 'Object'),
filename='Gear'
)
o = bpy.data.objects['Gear']
bpy.context.view_layer.objects.active = o
bpy.ops.transform.rotate(value=3.14/4,orient_axis='Y')
bpy.ops.transform.translate(value=(-4, 2, 5))
So in the test2.blend is an object named "Gear". When I start blender with blender.exe test1.blend --python .\import.py. the test2.blend is imported but then I get the error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "H:\Python\blender\.\import.py", line 19, in <module>
bpy.ops.transform.rotate(value=2.0,orient_axis='Y')
File "E:\Programme\Blender Foundation\Blender 3.1\3.1\scripts\modules\bpy\ops.py", line 132, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.transform.rotate.poll() failed, context is incorrect
When I comment out the line bpy.ops.transform.rotate the translate works just fine.
The interesting thing is, when blender opens with the quoted error, I can paste the code 1:1 in the Python console and it works.
I'm using Blender 3.1.2 on Windows 10.
Any Ideas?
I need help exporting the zenmap network topology graph to a PNG file automatically without having to open the zenmap and doing it manually.
I found a script on github but it's showing me an error:
#!/usr/bin/env python
import sys
if len(sys.argv) != 4:
print """{0} - Output a PNG from Nmap XML
Usage: {0} <scan.xml> <out.png> <width_in_pixels>""".format(sys.argv[0])
sys.exit(1)
try:
from zenmapGUI.TopologyPage import *
except ImportError:
import sys
sys.path.insert(0,"/usr/bin/zenmap")
from zenmapGUI.TopologyPage import *
t = TopologyPage(NetworkInventory(sys.argv[1]))
pix = int(sys.argv[3])
t.radialnet.set_allocation((0,0,pix,pix))
t.update_radialnet()
t.radialnet.save_drawing_to_file(sys.argv[2])
pradeep#ubuntu:~/Desktop$ python nmaptopng.py /home/pradeep/Desktop/topology.xml /home/pradeep/Desktop/xxx.png 500
Traceback (most recent call last):
File "nmaptopng.py", line 17, in <module>
t = TopologyPage(NetworkInventory(sys.argv[1]))
File "/usr/lib/python2.7/dist-packages/zenmapCore/NetworkInventory.py", line 145, in __init__
self.open_from_file(filename)
File "/usr/lib/python2.7/dist-packages/zenmapCore/NetworkInventory.py", line 315, in open_from_file
parsed = NmapParser(path)
TypeError: nmap_parser_sax() takes no arguments (1 given)
I tried looking for the NetworkInventory.py file in zenmap but failed to understand the problem! Can anyone help me with this?
I have been trying to make a basic speech recognition system in python, using pyttx, however, when i run my code:
import speech_recognition
import pyttsx
I get this error:
Traceback (most recent call last):
File "C:\Users\brett\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyttsx__init__.py", line 37, in init
eng = _activeEngines[driverName]
File "C:\Users\brett\AppData\Local\Programs\Python\Python36-32\lib\weakref.py", line 131, in getitem
o = self.datakey
KeyError: 'sapi5'
I have tried all solutions on here so far and none of them work, if i try to run the engine driver in pyttsx, I get an error with the driver.py, saying 'main' is not a pack. if i have left out any other info, just let me know
from PIL import Image
from pytesser import *
image_file = 'D:\plate.jpg'
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print "=====output=======\n"
print text
it gets me error that
C:\Users\KEN\Anaconda2\python.exe C:/Users/KENIL/PycharmProjects/plate/ocr.py
Traceback (most recent call last):
File "C:/Users/KEN/PycharmProjects/plate/ocr.py", line 2, in <module>
from pytesser import *
File "C:\Users\KEN\PycharmProjects\plate\pytesser.py", line 6, in <module>
import Image
ImportError: No module named Image
even though i have installed ananconda properly as well as pillow screenshot of package installed
The code you posted doesn't have the error. From the error message it seems that the error is in the module pytesser.py, where you probably use Image (in line 6 :-) ) without importing it.
I'm trying to write an OCR script with Python (2.7, Windows OS) to get text from images. First I've downloaded PyTesser and extracted it to Python27/Lib/site-packages as 'pytesser' and I've installed tesseract with pip install tesseract . Then I wrote the following script as self.py:
from PIL import Image
from pytesser.pytesser import *
image_file = 'C:/Users/blabla/test.png'
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print text
But I'm getting the following error:
Traceback (most recent call last):
File "C:/Users/blabla/self.py", line 7, in <module>
text = image_file_to_string(image_file)
File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 44, in image_file_to_string
call_tesseract(filename, scratch_text_name_root)
File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 24, in call_tesseract
errors.check_for_errors()
File "C:\Python27\lib\site-packages\pytesser\errors.py", line 10, in check_for_errors
inf = file(logfile)
IOError: [Errno 2] No such file or directory: 'tesseract.log'
And yes, there's no 'tesseract.log' file anywhere. What should I do? How should I solve this problem?
Thank you in advance.
Note: I've changed the line tesseract_exe_name from pytesser.py from tesseract to C:/Python27/Lib/site-packages/pytesser/tesseract but it doesn't work.
Edit: Alright, I've just runned teseract.exe that is in 'pytesser' and it created the 'tesseract.log' file but I'm still getting same error.
I've changed the line from def check_for_errors(logfile = "tesseract.log"): to def check_for_errors(logfile = "C:/Python27/Lib/site-packages/pytesser/tesseract.log"): in ../pytesser/errors.py and it worked.