segmenter: don't push to pipe if the pipe if full
(cherry picked from commit 1c5a94e605f7ab52efc6fb2b2fdeefdf2c4ab2e3)
This commit is contained in:
parent
36eccd43f2
commit
8732f8729f
|
@ -390,11 +390,16 @@ class SegmenterProcess(multiprocessing.Process):
|
|||
}
|
||||
|
||||
def _stream(self, img):
|
||||
def pipe_full(conn):
|
||||
r, w, x = select.select([], [conn], [], 0.0)
|
||||
return len(w) == 0
|
||||
|
||||
img_object = io.BytesIO()
|
||||
PIL.Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)).save(
|
||||
img_object, format="JPEG"
|
||||
)
|
||||
logger.debug("Sending the object in the pipe!")
|
||||
if not pipe_full(planktoscope.segmenter.streamer.sender):
|
||||
planktoscope.segmenter.streamer.sender.send(img_object)
|
||||
|
||||
def _slice_image(self, img, name, mask, start_count=0):
|
||||
|
|
Loading…
Reference in a new issue