diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1992-12-14 12:25:21 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1992-12-14 12:25:21 (GMT) |
commit | 3b25371ef12a15800dd6d1a9599c8d1a3dbb696b (patch) | |
tree | c5db3ff7ad97f1d9b03e4225aeb8be63c83beb8d /Demo/sgi/video/LiveVideoIn.py | |
parent | cf5dd9cbfda918b417a17d4413b7d099d3f47aaa (diff) | |
download | cpython-3b25371ef12a15800dd6d1a9599c8d1a3dbb696b.zip cpython-3b25371ef12a15800dd6d1a9599c8d1a3dbb696b.tar.gz cpython-3b25371ef12a15800dd6d1a9599c8d1a3dbb696b.tar.bz2 |
Changes for supporting monochrome and greyscale video (not yet fully
functional)
Diffstat (limited to 'Demo/sgi/video/LiveVideoIn.py')
-rwxr-xr-x | Demo/sgi/video/LiveVideoIn.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Demo/sgi/video/LiveVideoIn.py b/Demo/sgi/video/LiveVideoIn.py index 3fd8093..d0ea858 100755 --- a/Demo/sgi/video/LiveVideoIn.py +++ b/Demo/sgi/video/LiveVideoIn.py @@ -33,7 +33,7 @@ class LiveVideoIn: # Note that the data has to be cropped unless vw and vh are # just right for the video board (vw:vh == 4:3 and vh even). - def init(self, pktmax, vw, vh): + def init(self, pktmax, vw, vh, type): if not have_video: raise RuntimeError, 'no video available' if vw % 4 != 0: @@ -43,6 +43,14 @@ class LiveVideoIn: if realvw < vw: realvw = vw self.realwidth, self.realheight = v.QuerySize(realvw, vh) + if not type in ('rgb8', 'grey', 'mono'): + raise 'Incorrent video data type' + self.type = type + if type in ('grey', 'mono'): + v.SetParam([SV.COLOR, SV.MONO, SV.INPUT_BYPASS, 1]) + else: + v.SetParam([SV.COLOR, SV.DEFAULT_COLOR, \ + SV.INPUT_BYPASS, 0]) # Initialize capture (mode, self.realwidth, self.realheight, qsize, rate) = \ v.InitContinuousCapture(SV.RGB8_FRAMES, \ @@ -70,7 +78,7 @@ class LiveVideoIn: def resizevideo(self, vw, vh): self.close() - self = self.init(self.pktmax, vw, vh) + self = self.init(self.pktmax, vw, vh, self.type) # Remove an instance. # This turns off continuous capture. @@ -105,8 +113,14 @@ class LiveVideoIn: self.x1, self.y1) self.lpos = 0 self.dataoffset = 0 + if self.type == 'mono': + self.data = imageop.dither2mono(self.data, \ + self.width, self.height) data = self.data[self.dataoffset:self.dataoffset+self.pktsize] lpos = self.lpos self.dataoffset = self.dataoffset + self.pktsize - self.lpos = self.lpos + self.lpp + if self.type == 'mono': + self.lpos = self.lpos + self.lpp*8 + else: + self.lpos = self.lpos + self.lpp return lpos, data |