def _exportVideoThread(self):
ww = self.display.widget
n = None
if self.pAnnotate.value():
n = self.display.layerNames()
videoWrite(self.pPath.value(), ww.image,
levels=ww.item.levels,
shape=(self.pHeight.value(), self.pWidth.value()),
frames=self.pFrames.value(),
annotate_names=n,
lut=ww.item.lut, updateFn=self._thread.sigUpdate)
#
# fourcc = cv2.VideoWriter_fourcc(*'XVID')
# ww = self.display.widget
# im = ww.image
# if self.pResize.value():
# w, h = (self.pWidth.value(), self.pHeight.value())
# im = [cv2.resize(i, (w, h)) for i in im]
# else:
# h, w = im.shape[1:3]
# fr = self.pFrames.value()
# pa = self.pPath.value()
# assert pa[-3:] in ('avi',
# 'png'), 'video export only supports *.avi or *.png'
# isVideo = pa[-3:] == 'avi'
# if isVideo:
# cap = cv2.VideoCapture(0)
# # im.ndim==4)
# out = cv2.VideoWriter(pa, fourcc, fr, (w, h), isColor=1)
#
# times = np.linspace(0, len(im), len(im) * fr)
# interpolator = LinearInterpolateImageStack(im)
#
# lut = ww.item.lut
# if lut is not None:
# lut = lut(im[0])
#
# for n, time in enumerate(times):
# # update progress:
# self._thread.sigUpdate.emit(100 * n / len(times))
# image = interpolator(time)
#
# argb = makeRGBA(image, lut=lut,
# levels=ww.item.levels)[0]
# cimg = cv2.cvtColor(argb, cv2.COLOR_RGBA2BGR)
#
# if isVideo:
# out.write(cimg)
# else:
# cv2.imwrite('%s_%i_%.3f.png' % (pa[:-4], n, time), cimg)
#
# if isVideo:
# cap.release()
# out.release()
评论列表
文章目录