visionTest.py
Go to the documentation of this file.
1 import time
2 import rtm
3 rtm.nshost = "localhost"
4 rtm.nsport = 2809
6 
7 from Img import *
8 
9 def capture():
10  global vc, civ, ccs
11  mgr = rtm.findRTCmanager()
12  mgr.load("VideoCapture")
13  mgr.load("CameraImageViewer")
14 
15  vc = mgr.create("VideoCapture")
16  civ = mgr.create("CameraImageViewer")
17 
18  ccs = rtm.narrow(vc.service("service0"), "CameraCaptureService", "Img")
19 
20  rtm.connectPorts(vc.port("CameraImage"), civ.port("imageIn"))
21  rtm.serializeComponents([vc, civ])
22  vc.start()
23  civ.start()
24 
25 def rgb2gray():
26  mgr = rtm.findRTCmanager()
27  mgr.load("VideoCapture")
28  mgr.load("RGB2Gray")
29  mgr.load("CameraImageViewer")
30 
31  vc = mgr.create("VideoCapture")
32  r2g = mgr.create("RGB2Gray")
33  civ = mgr.create("CameraImageViewer")
34 
35  rtm.connectPorts(vc.port("CameraImage"), r2g.port("rgb"))
36  rtm.connectPorts(r2g.port("gray"), civ.port("imageIn"))
37  rtm.serializeComponents([vc, r2g, civ])
38  vc.start()
39  r2g.start()
40  civ.start()
41 
42 def jpeg():
43  global vc,je,jd,civ
44  mgr = rtm.findRTCmanager()
45  mgr.load("VideoCapture")
46  mgr.load("JpegEncoder")
47  mgr.load("JpegDecoder")
48  mgr.load("CameraImageViewer")
49 
50  vc = mgr.create("VideoCapture")
51  je = mgr.create("JpegEncoder")
52  jd = mgr.create("JpegDecoder")
53  civ = mgr.create("CameraImageViewer")
54 
55  rtm.connectPorts(vc.port("CameraImage"), je.port("decoded"))
56  rtm.connectPorts(je.port("encoded"), jd.port("encoded"))
57  rtm.connectPorts(jd.port("decoded"), civ.port("imageIn"))
58  rtm.serializeComponents([vc, je, jd, civ])
59  vc.start()
60  je.start()
61  jd.start()
62  civ.start()
63  time.sleep(3)
64  print "jpeg quality 95 -> 30"
65  je.setProperty("quality", "30")
66 
67 
68 def resize():
69  global vc, ri, civ
70  mgr = rtm.findRTCmanager()
71  mgr.load("VideoCapture")
72  mgr.load("ResizeImage")
73  mgr.load("CameraImageViewer")
74 
75  vc = mgr.create("VideoCapture")
76  ri = mgr.create("ResizeImage")
77  civ = mgr.create("CameraImageViewer")
78 
79  ri.setProperty("scale", "0.5")
80 
81  rtm.connectPorts(vc.port("CameraImage"), ri.port("original"))
82  rtm.connectPorts(ri.port("resized"), civ.port("imageIn"))
83  rtm.serializeComponents([vc, ri, civ])
84  vc.start()
85  ri.start()
86  civ.start()
87 
88 def total():
89  global vc, rg2, ri, je, jd, civ
90  mgr = rtm.findRTCmanager()
91  mgr.load("VideoCapture")
92  mgr.load("RGB2Gray")
93  mgr.load("ResizeImage")
94  mgr.load("JpegEncoder")
95  mgr.load("JpegDecoder")
96  mgr.load("CameraImageViewer")
97 
98  vc = mgr.create("VideoCapture")
99  r2g = mgr.create("RGB2Gray")
100  ri = mgr.create("ResizeImage")
101  je = mgr.create("JpegEncoder")
102  jd = mgr.create("JpegDecoder")
103  civ = mgr.create("CameraImageViewer")
104 
105  ri.setProperty("scale", "0.5")
106 
107  rtm.connectPorts(vc.port("CameraImage"), r2g.port("rgb"))
108  rtm.connectPorts(r2g.port("gray"), ri.port("original"))
109  rtm.connectPorts(ri.port("resized"), je.port("decoded"))
110  rtm.connectPorts(je.port("encoded"), jd.port("encoded"))
111  rtm.connectPorts(jd.port("decoded"), civ.port("imageIn"))
112  rtm.serializeComponents([vc, r2g, ri, je, jd, civ])
113  vc.start()
114  r2g.start()
115  ri.start()
116  je.start()
117  jd.start()
118  civ.start()
119 
120 
121 #total()
def capture()
Definition: visionTest.py:9
def rgb2gray()
Definition: visionTest.py:25
def resize()
Definition: visionTest.py:68
def jpeg()
Definition: visionTest.py:42
def narrow(ior, klass, package="OpenHRP")
narrow ior
Definition: jython/rtm.py:709
def serializeComponents(rtcs, stopEC=True)
set up execution context of the first RTC so that RTCs are executed sequentially
Definition: jython/rtm.py:373
def findRTCmanager(hostname=None, rnc=None)
get RTCmanager
Definition: jython/rtm.py:321
def connectPorts(outP, inPs, subscription="flush", dataflow="Push", bufferlength=1, rate=1000)
connect ports
Definition: jython/rtm.py:433
def total()
Definition: visionTest.py:88
def initCORBA()
initialize ORB
Definition: jython/rtm.py:272


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:51