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,12 +390,17 @@ class SegmenterProcess(multiprocessing.Process):
|
||||||
}
|
}
|
||||||
|
|
||||||
def _stream(self, img):
|
def _stream(self, img):
|
||||||
|
def pipe_full(conn):
|
||||||
|
r, w, x = select.select([], [conn], [], 0.0)
|
||||||
|
return len(w) == 0
|
||||||
|
|
||||||
img_object = io.BytesIO()
|
img_object = io.BytesIO()
|
||||||
PIL.Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)).save(
|
PIL.Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)).save(
|
||||||
img_object, format="JPEG"
|
img_object, format="JPEG"
|
||||||
)
|
)
|
||||||
logger.debug("Sending the object in the pipe!")
|
logger.debug("Sending the object in the pipe!")
|
||||||
planktoscope.segmenter.streamer.sender.send(img_object)
|
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):
|
def _slice_image(self, img, name, mask, start_count=0):
|
||||||
"""Slice a given image using give mask
|
"""Slice a given image using give mask
|
||||||
|
|
Loading…
Reference in a new issue