morefigs / pymba

Python wrapper for Allied Vision's Vimba C API
MIT License
105 stars 84 forks source link

Black Lines on readings #28

Closed Gloweye closed 8 years ago

Gloweye commented 8 years ago

I've been getting black lines on my pictures lately, and I haven't been able to find out why.

Script: frame is...a frame. image is externally triggered, but I've also seen it happen in internal triggers. All of this is done in it's own dedicated thread.

#Here's a lot of setup code
a = frame.waitFrameCapture(timeout = self.timeout*1000)# convert to milliseconds
print("Errorcode:",a)
timer_abort_queue.put((timerID,)) #Logs the duration taken from the main thread
cameraref.endCapture()
try:
     b = np.ndarray(buffer = frame.getBufferByteData(),
                              dtype = np.uint8,
                              shape = (frame.width,frame.height))
     print(b.shape)
     print(b)
 except:
      raise
cameraref.revokeAllFrames()
if a == 0:
      self.queue.put((identifierstring,copy.deepcopy(b)))  #gives the array to the main thread so enable processing of the data

Example of a black lined result is like this: black lines

What I considered:

Side note: Vimba Viewer itself doesn't seem to exhibit this problem. Or maybe it ignores to faulty frames someway.

I couldn't find any issues like this anywhere. If there's someone who has an idea, I'd love to hear it.

My apologies if it isn't a pymba issue. Right now it's a possibility, as I haven't been able to find other cases outside(or inside) pymba, but i don't have a clue as to what inside pymba could probably cause it either. To my limited knowledge, every line of pymba code looks fine.

morefigs commented 8 years ago

Do you get the same problem if you run a super simple script (like that in the Pymba readme) without threading, etc? Your camera calls are slightly different too, e.g. endCapture() is called before you access the frame (that may well matter).

rbogle commented 8 years ago

I found this problem on my jai cameras using the GigE via python-aravis. Ultimately it was network latency causing packet timeouts and incomplete frame buffers. I dont remember with pymba, can you check the buffer status to see if the buffer is complete/ready? Non-specific to pymba: I also was able to increase the packet delay & packet size (GevSCPD, GevSCPSPacketSize) in the GigE protocol to make packet timeouts much less likely. Lastly check the MTU of your eth adapter and see if you can bump that up, perhaps it got reset?

morefigs commented 8 years ago

Also ensure you are using 1000Mbps (not 10/100Mbps) switches and network cards.

Gloweye commented 8 years ago

I seem to be unable to replicate it right now, using the exact same script and settings. If I find a more reliable way, I'll let all of you know. For the rest, i just suggest we keep our eyes open if something like it happens.

(well, I changed some code, but that shouldn't be related..mainly, the generation of the triggering signal. However, the hardware that produces this signal is the exact same device in the exact same settings.)