Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3b25371e
Kaydet (Commit)
3b25371e
authored
Ara 14, 1992
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Changes for supporting monochrome and greyscale video (not yet fully
functional)
üst
cf5dd9cb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
185 additions
and
46 deletions
+185
-46
LiveVideoIn.py
Demo/sgi/video/LiveVideoIn.py
+17
-3
LiveVideoOut.py
Demo/sgi/video/LiveVideoOut.py
+13
-6
VFile.py
Demo/sgi/video/VFile.py
+8
-3
Vrec.py
Demo/sgi/video/Vrec.py
+101
-25
Vreceive.py
Demo/sgi/video/Vreceive.py
+7
-3
Vsend.py
Demo/sgi/video/Vsend.py
+8
-4
vcopy.py
Demo/sgi/video/vcopy.py
+31
-2
No files found.
Demo/sgi/video/LiveVideoIn.py
Dosyayı görüntüle @
3b25371e
...
@@ -33,7 +33,7 @@ class LiveVideoIn:
...
@@ -33,7 +33,7 @@ class LiveVideoIn:
# Note that the data has to be cropped unless vw and vh are
# 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).
# 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
:
if
not
have_video
:
raise
RuntimeError
,
'no video available'
raise
RuntimeError
,
'no video available'
if
vw
%
4
!=
0
:
if
vw
%
4
!=
0
:
...
@@ -43,6 +43,14 @@ class LiveVideoIn:
...
@@ -43,6 +43,14 @@ class LiveVideoIn:
if
realvw
<
vw
:
if
realvw
<
vw
:
realvw
=
vw
realvw
=
vw
self
.
realwidth
,
self
.
realheight
=
v
.
QuerySize
(
realvw
,
vh
)
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
# Initialize capture
(
mode
,
self
.
realwidth
,
self
.
realheight
,
qsize
,
rate
)
=
\
(
mode
,
self
.
realwidth
,
self
.
realheight
,
qsize
,
rate
)
=
\
v
.
InitContinuousCapture
(
SV
.
RGB8_FRAMES
,
\
v
.
InitContinuousCapture
(
SV
.
RGB8_FRAMES
,
\
...
@@ -70,7 +78,7 @@ class LiveVideoIn:
...
@@ -70,7 +78,7 @@ class LiveVideoIn:
def
resizevideo
(
self
,
vw
,
vh
):
def
resizevideo
(
self
,
vw
,
vh
):
self
.
close
()
self
.
close
()
self
=
self
.
init
(
self
.
pktmax
,
vw
,
vh
)
self
=
self
.
init
(
self
.
pktmax
,
vw
,
vh
,
self
.
type
)
# Remove an instance.
# Remove an instance.
# This turns off continuous capture.
# This turns off continuous capture.
...
@@ -105,8 +113,14 @@ class LiveVideoIn:
...
@@ -105,8 +113,14 @@ class LiveVideoIn:
self
.
x1
,
self
.
y1
)
self
.
x1
,
self
.
y1
)
self
.
lpos
=
0
self
.
lpos
=
0
self
.
dataoffset
=
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
]
data
=
self
.
data
[
self
.
dataoffset
:
self
.
dataoffset
+
self
.
pktsize
]
lpos
=
self
.
lpos
lpos
=
self
.
lpos
self
.
dataoffset
=
self
.
dataoffset
+
self
.
pktsize
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
return
lpos
,
data
Demo/sgi/video/LiveVideoOut.py
Dosyayı görüntüle @
3b25371e
...
@@ -12,13 +12,15 @@ class LiveVideoOut:
...
@@ -12,13 +12,15 @@ class LiveVideoOut:
# wid: the window id where the video is to be displayed (centered)
# wid: the window id where the video is to be displayed (centered)
# vw, vh: size of the video image to be displayed
# vw, vh: size of the video image to be displayed
def
init
(
self
,
wid
,
vw
,
vh
):
def
init
(
self
,
wid
,
vw
,
vh
,
type
):
##print 'Init', wid, xywh
##print 'Init', wid, xywh
##print 'video', vw, vw
##print 'video', vw, vw
self
.
vw
=
vw
self
.
vw
=
vw
self
.
vh
=
vh
self
.
vh
=
vh
self
.
disp
=
Displayer
()
.
init
()
self
.
disp
=
Displayer
()
.
init
()
info
=
(
'rgb8'
,
vw
,
vh
,
1
,
8
,
0
,
0
,
0
,
0
)
if
not
type
in
(
'rgb8'
,
'grey'
,
'mono'
):
raise
'Incorrent live video output type'
info
=
(
type
,
vw
,
vh
,
1
,
8
,
0
,
0
,
0
,
0
)
self
.
disp
.
setinfo
(
info
)
self
.
disp
.
setinfo
(
info
)
self
.
wid
=
wid
self
.
wid
=
wid
oldwid
=
gl
.
winget
()
oldwid
=
gl
.
winget
()
...
@@ -56,10 +58,15 @@ class LiveVideoOut:
...
@@ -56,10 +58,15 @@ class LiveVideoOut:
# LiveVideoIn.getnextpacket()).
# LiveVideoIn.getnextpacket()).
def
putnextpacket
(
self
,
pos
,
data
):
def
putnextpacket
(
self
,
pos
,
data
):
nline
=
len
(
data
)
/
self
.
vw
if
self
.
disp
.
format
==
'mono'
:
if
nline
*
self
.
vw
<>
len
(
data
):
# Unfortunately size-check is difficult for
print
'Incorrect-sized video fragment ignored'
# packed video
return
nline
=
(
len
(
data
)
*
8
)
/
self
.
vw
else
:
nline
=
len
(
data
)
/
self
.
vw
if
nline
*
self
.
vw
<>
len
(
data
):
print
'Incorrect-sized video fragment ignored'
return
oldwid
=
gl
.
winget
()
oldwid
=
gl
.
winget
()
gl
.
winset
(
self
.
wid
)
gl
.
winset
(
self
.
wid
)
self
.
disp
.
showpartframe
(
data
,
None
,
(
0
,
pos
,
self
.
vw
,
nline
))
self
.
disp
.
showpartframe
(
data
,
None
,
(
0
,
pos
,
self
.
vw
,
nline
))
...
...
Demo/sgi/video/VFile.py
Dosyayı görüntüle @
3b25371e
...
@@ -73,6 +73,7 @@ def conv_jpeg(r, g, b):
...
@@ -73,6 +73,7 @@ def conv_jpeg(r, g, b):
raise
Error
,
'Attempt to make RGB colormap (jpeg)'
raise
Error
,
'Attempt to make RGB colormap (jpeg)'
conv_jpeggrey
=
conv_grey
conv_jpeggrey
=
conv_grey
conv_mono
=
conv_grey
# Choose one of the above based upon a color system name
# Choose one of the above based upon a color system name
...
@@ -213,7 +214,8 @@ class VideoParams:
...
@@ -213,7 +214,8 @@ class VideoParams:
def
init
(
self
):
def
init
(
self
):
# Essential parameters
# Essential parameters
self
.
format
=
'grey'
# color system used
self
.
format
=
'grey'
# color system used
# Choose from: grey, rgb, rgb8, hsv, yiq, hls, jpeg, jpeggrey
# Choose from: grey, rgb, rgb8, hsv, yiq, hls, jpeg, jpeggrey,
# mono
self
.
width
=
0
# width of frame
self
.
width
=
0
# width of frame
self
.
height
=
0
# height of frame
self
.
height
=
0
# height of frame
self
.
packfactor
=
1
# expansion using rectzoom
self
.
packfactor
=
1
# expansion using rectzoom
...
@@ -315,6 +317,9 @@ class Displayer(VideoParams):
...
@@ -315,6 +317,9 @@ class Displayer(VideoParams):
p
=
pf
p
=
pf
if
(
width
,
height
,
bytes
)
<>
(
w
/
p
,
h
/
p
,
b
):
if
(
width
,
height
,
bytes
)
<>
(
w
/
p
,
h
/
p
,
b
):
raise
Error
,
'jpeg data has wrong size'
raise
Error
,
'jpeg data has wrong size'
elif
self
.
format
==
'mono'
:
import
imageop
data
=
imageop
.
mono2grey
(
data
,
w
,
h
,
0x20
,
0xdf
)
if
not
self
.
colormapinited
:
if
not
self
.
colormapinited
:
self
.
initcolormap
()
self
.
initcolormap
()
if
self
.
fixcolor0
:
if
self
.
fixcolor0
:
...
@@ -544,7 +549,7 @@ def readfileheader(fp, filename):
...
@@ -544,7 +549,7 @@ def readfileheader(fp, filename):
c0bits
=
c1bits
=
c2bits
=
0
c0bits
=
c1bits
=
c2bits
=
0
chrompack
=
0
chrompack
=
0
offset
=
0
offset
=
0
elif
format
in
(
'grey'
,
'jpeggrey'
):
elif
format
in
(
'grey'
,
'jpeggrey'
,
'mono'
):
c0bits
=
rest
c0bits
=
rest
c1bits
=
c2bits
=
0
c1bits
=
c2bits
=
0
chrompack
=
0
chrompack
=
0
...
@@ -642,7 +647,7 @@ def writefileheader(fp, values):
...
@@ -642,7 +647,7 @@ def writefileheader(fp, values):
#
#
if
format
in
(
'rgb'
,
'jpeg'
):
if
format
in
(
'rgb'
,
'jpeg'
):
data
=
(
format
,
0
)
data
=
(
format
,
0
)
elif
format
in
(
'grey'
,
'jpeggrey'
):
elif
format
in
(
'grey'
,
'jpeggrey'
,
'mono'
):
data
=
(
format
,
c0bits
)
data
=
(
format
,
c0bits
)
else
:
else
:
data
=
(
format
,
(
c0bits
,
c1bits
,
c2bits
,
chrompack
,
offset
))
data
=
(
format
,
(
c0bits
,
c1bits
,
c2bits
,
chrompack
,
offset
))
...
...
Demo/sgi/video/Vrec.py
Dosyayı görüntüle @
3b25371e
...
@@ -15,6 +15,11 @@
...
@@ -15,6 +15,11 @@
# -q queuesize : set the capture queue size (default 2)
# -q queuesize : set the capture queue size (default 2)
# -r rate : capture 1 out of every 'rate' frames (default and min 2)
# -r rate : capture 1 out of every 'rate' frames (default and min 2)
# -w width : initial window width (default interactive placement)
# -w width : initial window width (default interactive placement)
# -n : Don't write to file, only timing info
# -d : drop fields if needed
# -g : greyscale
# -m : monochrome dithered
# -M value : monochrome tresholded with value
#
#
# moviefile : here goes the movie data (default film.video);
# moviefile : here goes the movie data (default film.video);
# the format is documented in cmif-film.ms
# the format is documented in cmif-film.ms
...
@@ -47,7 +52,7 @@ import time
...
@@ -47,7 +52,7 @@ import time
import
posix
import
posix
import
getopt
import
getopt
import
string
import
string
import
imageop
# Main program
# Main program
...
@@ -57,8 +62,13 @@ def main():
...
@@ -57,8 +62,13 @@ def main():
audio
=
0
audio
=
0
rate
=
2
rate
=
2
width
=
0
width
=
0
norecord
=
0
drop
=
0
mono
=
0
grey
=
0
monotreshold
=
-
1
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'aq:r:w:'
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'aq:r:w:
ndgmM:
'
)
for
opt
,
arg
in
opts
:
for
opt
,
arg
in
opts
:
if
opt
==
'-a'
:
if
opt
==
'-a'
:
audio
=
1
audio
=
1
...
@@ -71,6 +81,17 @@ def main():
...
@@ -71,6 +81,17 @@ def main():
sys
.
exit
(
2
)
sys
.
exit
(
2
)
elif
opt
==
'-w'
:
elif
opt
==
'-w'
:
width
=
string
.
atoi
(
arg
)
width
=
string
.
atoi
(
arg
)
elif
opt
==
'-n'
:
norecord
=
1
elif
opt
==
'-d'
:
drop
=
1
elif
opt
==
'-g'
:
grey
=
1
elif
opt
==
'-m'
:
mono
=
1
elif
opt
==
'-M'
:
mono
=
1
monotreshold
=
string
.
atoi
(
arg
)
if
args
[
2
:]:
if
args
[
2
:]:
sys
.
stderr
.
write
(
'usage: Vrec [options] [file [audiofile]]
\n
'
)
sys
.
stderr
.
write
(
'usage: Vrec [options] [file [audiofile]]
\n
'
)
...
@@ -93,6 +114,8 @@ def main():
...
@@ -93,6 +114,8 @@ def main():
else
:
else
:
audiofilename
=
None
audiofilename
=
None
if
norecord
:
filename
=
audiofilename
=
''
v
=
sv
.
OpenVideo
()
v
=
sv
.
OpenVideo
()
# Determine maximum window size based on signal standard
# Determine maximum window size based on signal standard
param
=
[
SV
.
BROADCAST
,
0
]
param
=
[
SV
.
BROADCAST
,
0
]
...
@@ -123,11 +146,25 @@ def main():
...
@@ -123,11 +146,25 @@ def main():
print
x
,
'x'
,
y
print
x
,
'x'
,
y
v
.
SetSize
(
x
,
y
)
v
.
SetSize
(
x
,
y
)
<<<<<<<
Vrec
.
py
if
drop
:
param
=
[
SV
.
FIELDDROP
,
1
,
SV
.
GENLOCK
,
SV
.
GENLOCK_OFF
]
else
:
param
=
[
SV
.
FIELDDROP
,
0
,
SV
.
GENLOCK
,
SV
.
GENLOCK_ON
]
if
mono
or
grey
:
param
=
param
+
[
SV
.
COLOR
,
SV
.
MONO
,
SV
.
INPUT_BYPASS
,
1
]
else
:
param
=
param
+
[
SV
.
COLOR
,
SV
.
DEFAULT_COLOR
,
SV
.
INPUT_BYPASS
,
0
]
v
.
SetParam
(
param
)
=======
# VERY IMPORTANT (for PAL at least): don't drop fields!
# VERY IMPORTANT (for PAL at least): don't drop fields!
param
=
[
SV
.
FIELDDROP
,
0
]
param
=
[
SV
.
FIELDDROP
,
0
]
v
.
SetParam
(
param
)
v
.
SetParam
(
param
)
>>>>>>>
1.7
v
.
BindGLWindow
(
win
,
SV
.
IN_REPLACE
)
v
.
BindGLWindow
(
win
,
SV
.
IN_REPLACE
)
gl
.
qdevice
(
DEVICE
.
LEFTMOUSE
)
gl
.
qdevice
(
DEVICE
.
LEFTMOUSE
)
...
@@ -142,7 +179,8 @@ def main():
...
@@ -142,7 +179,8 @@ def main():
if
dev
==
DEVICE
.
LEFTMOUSE
:
if
dev
==
DEVICE
.
LEFTMOUSE
:
if
val
==
1
:
if
val
==
1
:
info
=
format
,
x
,
y
,
qsize
,
rate
info
=
format
,
x
,
y
,
qsize
,
rate
record
(
v
,
info
,
filename
,
audiofilename
)
record
(
v
,
info
,
filename
,
audiofilename
,
\
mono
,
grey
,
monotreshold
)
elif
dev
==
DEVICE
.
REDRAW
:
elif
dev
==
DEVICE
.
REDRAW
:
# Window resize (or move)
# Window resize (or move)
x
,
y
=
gl
.
getsize
()
x
,
y
=
gl
.
getsize
()
...
@@ -159,31 +197,41 @@ def main():
...
@@ -159,31 +197,41 @@ def main():
# Record until the mouse is released (or any other GL event)
# Record until the mouse is released (or any other GL event)
# XXX audio not yet supported
# XXX audio not yet supported
def
record
(
v
,
info
,
filename
,
audiofilename
):
def
record
(
v
,
info
,
filename
,
audiofilename
,
mono
,
grey
,
monotreshold
):
import
thread
import
thread
format
,
x
,
y
,
qsize
,
rate
=
info
format
,
x
,
y
,
qsize
,
rate
=
info
fps
=
59.64
# Fields per second
fps
=
59.64
# Fields per second
# XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!)
# XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!)
tpf
=
1000.0
/
fps
# Time per field in msec
tpf
=
1000.0
/
fps
# Time per field in msec
vout
=
VFile
.
VoutFile
()
.
init
(
filename
)
if
filename
:
vout
.
format
=
'rgb8'
vout
=
VFile
.
VoutFile
()
.
init
(
filename
)
vout
.
width
=
x
if
mono
:
vout
.
height
=
y
vout
.
format
=
'mono'
vout
.
writeheader
()
elif
grey
:
MAXSIZE
=
20
# XXX should be a user option
vout
.
format
=
'grey'
import
Queue
else
:
queue
=
Queue
.
Queue
()
.
init
(
MAXSIZE
)
vout
.
format
=
'rgb8'
done
=
thread
.
allocate_lock
()
vout
.
width
=
x
done
.
acquire_lock
()
vout
.
height
=
y
thread
.
start_new_thread
(
saveframes
,
(
vout
,
queue
,
done
))
vout
.
writeheader
()
if
audiofilename
:
MAXSIZE
=
20
# XXX should be a user option
audiodone
=
thread
.
allocate_lock
()
import
Queue
audiodone
.
acquire_lock
()
queue
=
Queue
.
Queue
()
.
init
(
MAXSIZE
)
audiostop
=
[]
done
=
thread
.
allocate_lock
()
initaudio
(
audiofilename
,
audiostop
,
audiodone
)
done
.
acquire_lock
()
thread
.
start_new_thread
(
saveframes
,
\
(
vout
,
queue
,
done
,
mono
,
monotreshold
))
if
audiofilename
:
audiodone
=
thread
.
allocate_lock
()
audiodone
.
acquire_lock
()
audiostop
=
[]
initaudio
(
audiofilename
,
audiostop
,
audiodone
)
gl
.
wintitle
(
'(rec) '
+
filename
)
gl
.
wintitle
(
'(rec) '
+
filename
)
lastid
=
0
lastid
=
0
t0
=
time
.
millitimer
()
t0
=
time
.
millitimer
()
count
=
0
timestamps
=
[]
ids
=
[]
v
.
InitContinuousCapture
(
info
)
v
.
InitContinuousCapture
(
info
)
while
not
gl
.
qtest
():
while
not
gl
.
qtest
():
try
:
try
:
...
@@ -191,34 +239,62 @@ def record(v, info, filename, audiofilename):
...
@@ -191,34 +239,62 @@ def record(v, info, filename, audiofilename):
except
sv
.
error
:
except
sv
.
error
:
time
.
millisleep
(
10
)
# XXX is this necessary?
time
.
millisleep
(
10
)
# XXX is this necessary?
continue
continue
timestamps
.
append
(
time
.
millitimer
())
ids
.
append
(
id
)
id
=
id
+
2
*
rate
id
=
id
+
2
*
rate
## if id <> lastid + 2*rate:
## if id <> lastid + 2*rate:
## print lastid, id
## print lastid, id
lastid
=
id
lastid
=
id
data
=
cd
.
InterleaveFields
(
1
)
data
=
cd
.
InterleaveFields
(
1
)
cd
.
UnlockCaptureData
()
cd
.
UnlockCaptureData
()
queue
.
put
(
data
,
int
(
id
*
tpf
))
count
=
count
+
1
if
filename
:
queue
.
put
(
data
,
int
(
id
*
tpf
))
t1
=
time
.
millitimer
()
t1
=
time
.
millitimer
()
gl
.
wintitle
(
'(busy) '
+
filename
)
gl
.
wintitle
(
'(busy) '
+
filename
)
print
lastid
,
'fields in'
,
t1
-
t0
,
'msec'
,
print
lastid
,
'fields in'
,
t1
-
t0
,
'msec'
,
print
'--'
,
0.1
*
int
(
lastid
*
10000.0
/
(
t1
-
t0
)),
'fields/sec'
print
'--'
,
0.1
*
int
(
lastid
*
10000.0
/
(
t1
-
t0
)),
'fields/sec'
if
audiofilename
:
print
'Captured'
,
count
*
2
,
'fields,'
,
0.1
*
int
(
count
*
20000.0
/
(
t1
-
t0
)),
'f/s'
,
print
count
*
200.0
/
lastid
,
'
%
,'
,
print
count
*
rate
*
200.0
/
lastid
,
'
%
of wanted rate'
t0
=
timestamps
[
0
]
del
timestamps
[
0
]
print
'Times:'
,
for
t1
in
timestamps
:
print
t1
-
t0
,
t0
=
t1
print
print
'Ids:'
,
t0
=
ids
[
0
]
del
ids
[
0
]
for
t1
in
ids
:
print
t1
-
t0
,
t0
=
t1
print
if
filename
and
audiofilename
:
audiostop
.
append
(
None
)
audiostop
.
append
(
None
)
audiodone
.
acquire_lock
()
audiodone
.
acquire_lock
()
v
.
EndContinuousCapture
()
v
.
EndContinuousCapture
()
queue
.
put
(
None
)
# Sentinel
if
filename
:
done
.
acquire_lock
()
queue
.
put
(
None
)
# Sentinel
done
.
acquire_lock
()
gl
.
wintitle
(
'(done) '
+
filename
)
gl
.
wintitle
(
'(done) '
+
filename
)
# Thread to save the frames to the file
# Thread to save the frames to the file
def
saveframes
(
vout
,
queue
,
done
):
def
saveframes
(
vout
,
queue
,
done
,
mono
,
monotreshold
):
while
1
:
while
1
:
x
=
queue
.
get
()
x
=
queue
.
get
()
if
not
x
:
if
not
x
:
break
break
data
,
t
=
x
data
,
t
=
x
if
mono
and
monotreshold
>=
0
:
data
=
imageop
.
grey2mono
(
data
,
len
(
data
),
1
,
\
monotreshold
)
elif
mono
:
data
=
imageop
.
dither2mono
(
data
,
len
(
data
),
1
)
vout
.
writeframe
(
t
,
data
,
None
)
vout
.
writeframe
(
t
,
data
,
None
)
del
data
del
data
sys
.
stderr
.
write
(
'Done writing video
\n
'
)
sys
.
stderr
.
write
(
'Done writing video
\n
'
)
...
...
Demo/sgi/video/Vreceive.py
Dosyayı görüntüle @
3b25371e
...
@@ -23,9 +23,10 @@ from senddefs import *
...
@@ -23,9 +23,10 @@ from senddefs import *
def
usage
(
msg
):
def
usage
(
msg
):
print
msg
print
msg
print
'usage: Vreceive [-m mcastgrp] [-p port]'
print
'usage: Vreceive [-m mcastgrp] [-p port]
[-c type]
'
print
'-m mcastgrp: multicast group (default '
+
`DEFMCAST`
+
')'
print
'-m mcastgrp: multicast group (default '
+
`DEFMCAST`
+
')'
print
'-p port : port (default '
+
`DEFPORT`
+
')'
print
'-p port : port (default '
+
`DEFPORT`
+
')'
print
'-c type : signal type: rgb8, grey or mono (default rgb8)'
sys
.
exit
(
2
)
sys
.
exit
(
2
)
...
@@ -39,9 +40,10 @@ def main():
...
@@ -39,9 +40,10 @@ def main():
port
=
DEFPORT
port
=
DEFPORT
width
=
DEFWIDTH
width
=
DEFWIDTH
height
=
DEFHEIGHT
height
=
DEFHEIGHT
vtype
=
'rgb8'
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'm:p:'
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'm:p:
c:
'
)
except
getopt
.
error
,
msg
:
except
getopt
.
error
,
msg
:
usage
(
msg
)
usage
(
msg
)
...
@@ -51,6 +53,8 @@ def main():
...
@@ -51,6 +53,8 @@ def main():
port
=
string
.
atoi
(
optarg
)
port
=
string
.
atoi
(
optarg
)
if
opt
==
'-m'
:
if
opt
==
'-m'
:
group
=
gethostbyname
(
optarg
)
group
=
gethostbyname
(
optarg
)
if
opt
==
'-c'
:
vtype
=
optarg
except
string
.
atoi_error
,
msg
:
except
string
.
atoi_error
,
msg
:
usage
(
'bad integer: '
+
msg
)
usage
(
'bad integer: '
+
msg
)
...
@@ -64,7 +68,7 @@ def main():
...
@@ -64,7 +68,7 @@ def main():
gl
.
qdevice
(
DEVICE
.
WINSHUT
)
gl
.
qdevice
(
DEVICE
.
WINSHUT
)
gl
.
qdevice
(
DEVICE
.
WINQUIT
)
gl
.
qdevice
(
DEVICE
.
WINQUIT
)
lvo
=
LiveVideoOut
.
LiveVideoOut
()
.
init
(
wid
,
width
,
height
)
lvo
=
LiveVideoOut
.
LiveVideoOut
()
.
init
(
wid
,
width
,
height
,
vtype
)
ifdlist
=
[
gl
.
qgetfd
(),
s
.
fileno
()]
ifdlist
=
[
gl
.
qgetfd
(),
s
.
fileno
()]
ofdlist
=
[]
ofdlist
=
[]
...
...
Demo/sgi/video/Vsend.py
Dosyayı görüntüle @
3b25371e
...
@@ -22,7 +22,7 @@ from senddefs import *
...
@@ -22,7 +22,7 @@ from senddefs import *
def
usage
(
msg
):
def
usage
(
msg
):
print
msg
print
msg
print
'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl]'
,
print
'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl]
[-c type] [-m]
'
,
print
'[-w width] [host] ...'
print
'[-w width] [host] ...'
print
'-b : broadcast on local net'
print
'-b : broadcast on local net'
print
'-h height : window height (default '
+
`DEFHEIGHT`
+
')'
print
'-h height : window height (default '
+
`DEFHEIGHT`
+
')'
...
@@ -30,6 +30,7 @@ def usage(msg):
...
@@ -30,6 +30,7 @@ def usage(msg):
print
'-t ttl : time-to-live (multicast only; default 1)'
print
'-t ttl : time-to-live (multicast only; default 1)'
print
'-s size : max packet size (default '
+
`DEFPKTMAX`
+
')'
print
'-s size : max packet size (default '
+
`DEFPKTMAX`
+
')'
print
'-w width : window width (default '
+
`DEFWIDTH`
+
')'
print
'-w width : window width (default '
+
`DEFWIDTH`
+
')'
print
'-c type : Type: rgb8, mono or grey (default rgb8)'
print
'[host] ...: host(s) to send to (default multicast to '
+
\
print
'[host] ...: host(s) to send to (default multicast to '
+
\
DEFMCAST
+
')'
DEFMCAST
+
')'
sys
.
exit
(
2
)
sys
.
exit
(
2
)
...
@@ -44,9 +45,10 @@ def main():
...
@@ -44,9 +45,10 @@ def main():
pktmax
=
DEFPKTMAX
pktmax
=
DEFPKTMAX
width
=
DEFWIDTH
width
=
DEFWIDTH
height
=
DEFHEIGHT
height
=
DEFHEIGHT
vtype
=
'rgb8'
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'bh:p:s:t:w:'
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'bh:p:s:t:w:
c:
'
)
except
getopt
.
error
,
msg
:
except
getopt
.
error
,
msg
:
usage
(
msg
)
usage
(
msg
)
...
@@ -64,6 +66,8 @@ def main():
...
@@ -64,6 +66,8 @@ def main():
width
=
string
.
atoi
(
optarg
)
width
=
string
.
atoi
(
optarg
)
if
opt
==
'-h'
:
if
opt
==
'-h'
:
height
=
string
.
atoi
(
optarg
)
height
=
string
.
atoi
(
optarg
)
if
opt
==
'-c'
:
vtype
=
optarg
except
string
.
atoi_error
,
msg
:
except
string
.
atoi_error
,
msg
:
usage
(
'bad integer: '
+
msg
)
usage
(
'bad integer: '
+
msg
)
...
@@ -92,9 +96,9 @@ def main():
...
@@ -92,9 +96,9 @@ def main():
gl
.
qdevice
(
DEVICE
.
WINTHAW
)
gl
.
qdevice
(
DEVICE
.
WINTHAW
)
width
,
height
=
gl
.
getsize
()
width
,
height
=
gl
.
getsize
()
lvo
=
LiveVideoOut
.
LiveVideoOut
()
.
init
(
wid
,
width
,
height
)
lvo
=
LiveVideoOut
.
LiveVideoOut
()
.
init
(
wid
,
width
,
height
,
vtype
)
lvi
=
LiveVideoIn
.
LiveVideoIn
()
.
init
(
pktmax
,
width
,
height
)
lvi
=
LiveVideoIn
.
LiveVideoIn
()
.
init
(
pktmax
,
width
,
height
,
vtype
)
s
=
socket
(
AF_INET
,
SOCK_DGRAM
)
s
=
socket
(
AF_INET
,
SOCK_DGRAM
)
s
.
setsockopt
(
SOL_SOCKET
,
SO_BROADCAST
,
1
)
s
.
setsockopt
(
SOL_SOCKET
,
SO_BROADCAST
,
1
)
...
...
Demo/sgi/video/vcopy.py
Dosyayı görüntüle @
3b25371e
...
@@ -5,12 +5,18 @@ import getopt
...
@@ -5,12 +5,18 @@ import getopt
from
gl
import
*
from
gl
import
*
from
DEVICE
import
*
from
DEVICE
import
*
import
VFile
import
VFile
import
string
import
imageop
def
report
(
time
,
iframe
):
def
report
(
time
,
iframe
):
print
'Frame'
,
iframe
,
': t ='
,
time
print
'Frame'
,
iframe
,
': t ='
,
time
def
usage
():
def
usage
():
sys
.
stderr
.
write
(
'usage: vcopy infile outfile
\n
'
)
sys
.
stderr
.
write
(
'usage: vcopy [-t type] [-m treshold] [-a] infile outfile
\n
'
)
sys
.
stderr
.
write
(
'-t Convert to other type
\n
'
)
sys
.
stderr
.
write
(
'-a Automatic
\n
'
)
sys
.
stderr
.
write
(
'-m Convert grey to mono with treshold
\n
'
)
sys
.
stderr
.
write
(
'-d Convert grey to mono with dithering
\n
'
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
def
help
():
def
help
():
...
@@ -20,7 +26,7 @@ def help():
...
@@ -20,7 +26,7 @@ def help():
def
main
():
def
main
():
foreground
()
foreground
()
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
't:a'
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
't:a
m:d
'
)
if
len
(
args
)
<>
2
:
if
len
(
args
)
<>
2
:
usage
()
usage
()
[
ifile
,
ofile
]
=
args
[
ifile
,
ofile
]
=
args
...
@@ -33,12 +39,28 @@ def main():
...
@@ -33,12 +39,28 @@ def main():
use_grabber
=
0
use_grabber
=
0
continuous
=
0
continuous
=
0
tomono
=
0
tomonodither
=
0
for
o
,
a
in
opts
:
for
o
,
a
in
opts
:
if
o
==
'-t'
:
if
o
==
'-t'
:
ofilm
.
format
=
a
ofilm
.
format
=
a
use_grabber
=
1
use_grabber
=
1
if
o
==
'-a'
:
if
o
==
'-a'
:
continuous
=
1
continuous
=
1
if
o
==
'-m'
:
if
ifilm
.
format
<>
'grey'
:
print
'-m only supported for greyscale'
sys
.
exit
(
1
)
tomono
=
1
treshold
=
string
.
atoi
(
a
)
ofilm
.
format
=
'mono'
if
o
==
'-d'
:
if
ifilm
.
format
<>
'grey'
:
print
'-m only supported for greyscale'
sys
.
exit
(
1
)
tomonodither
=
1
ofilm
.
format
=
'mono'
ofilm
.
writeheader
()
ofilm
.
writeheader
()
#
#
prefsize
(
ifilm
.
width
,
ifilm
.
height
)
prefsize
(
ifilm
.
width
,
ifilm
.
height
)
...
@@ -83,6 +105,13 @@ def main():
...
@@ -83,6 +105,13 @@ def main():
if
c
==
'w'
or
continuous
:
if
c
==
'w'
or
continuous
:
if
use_grabber
:
if
use_grabber
:
data
,
cdata
=
ofilm
.
grabframe
()
data
,
cdata
=
ofilm
.
grabframe
()
if
tomono
:
data
=
imageop
.
grey2mono
(
data
,
\
ifilm
.
width
,
ifilm
.
height
,
\
treshold
)
if
tomonodither
:
data
=
imageop
.
dither2mono
(
data
,
\
ifilm
.
width
,
ifilm
.
height
)
ofilm
.
writeframe
(
time
,
data
,
cdata
)
ofilm
.
writeframe
(
time
,
data
,
cdata
)
print
'Frame'
,
iframe
,
'written.'
print
'Frame'
,
iframe
,
'written.'
if
c
==
'n'
or
continuous
:
if
c
==
'n'
or
continuous
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment