SaveToFile.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:dataArtist 作者: radjkarl 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号