i have following situation:
cratecolor.py: (code stripped to its minimum...)
import ... ...
class GetColorImage:
def __init__(self, ia=None):
self.path = None
self.img = None
self.img0 = None
self.s = None
self.basetime = 0
self.count = 0
self.stride = 32
self.ia = ia
self.img_size = 640
self.auto = True
self.getImage()
def getImage(self):
self.ia.remote_device.node_map.ExposureTime.value = 350
self.ia.remote_device.node_map.Gain.value = 150
...
...
print(color, l) # prints: 1 59.64829339143065
return color, l
main.py: (code stripped to its minimum)
...
...
# code exectued on a qthread:
def getcolor(self, idin):
color, lightness = cratecolor.GetColorImage(ia=self.ia) #******
print(color, lightness)
In the line marked with ***** i get the error message color, lightness = cratecolor.GetColorImage(ia=self.ia) TypeError: cannot unpack non-iterable GetColorImage object
but i dont get why.
any help appreciated.
You cannot return values from an __init__
function, so you instead must either:
getImage()
method when creating the class__iter__
method for the class to automatically allow you to assign it to multiple variables.The second one is probably the better solution. Here is the method you would add to the class for it to work:
def __iter__(self):
return iter(self.getImage())