v01
This commit is contained in:
66
thirdparty/Pangolin/pyexamples/SimpleDisplay.py
vendored
Executable file
66
thirdparty/Pangolin/pyexamples/SimpleDisplay.py
vendored
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
|
||||
sys.path.append("../build/src")
|
||||
|
||||
import pypangolin as pango
|
||||
from OpenGL.GL import *
|
||||
|
||||
|
||||
def a_callback():
|
||||
print("a pressed")
|
||||
|
||||
|
||||
def main():
|
||||
win = pango.CreateWindowAndBind("pySimpleDisplay", 640, 480)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
|
||||
pm = pango.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.1, 1000)
|
||||
mv = pango.ModelViewLookAt(-0, 0.5, -3, 0, 0, 0, pango.AxisY)
|
||||
s_cam = pango.OpenGlRenderState(pm, mv)
|
||||
|
||||
ui_width = 180
|
||||
|
||||
handler = pango.Handler3D(s_cam)
|
||||
d_cam = (
|
||||
pango.CreateDisplay()
|
||||
.SetBounds(
|
||||
pango.Attach(0),
|
||||
pango.Attach(1),
|
||||
pango.Attach.Pix(ui_width),
|
||||
pango.Attach(1),
|
||||
-640.0 / 480.0,
|
||||
)
|
||||
.SetHandler(handler)
|
||||
)
|
||||
|
||||
pango.CreatePanel("ui").SetBounds(
|
||||
pango.Attach(0), pango.Attach(1), pango.Attach(0), pango.Attach.Pix(ui_width)
|
||||
)
|
||||
var_ui = pango.Var("ui")
|
||||
var_ui.a_Button = False
|
||||
var_ui.a_double = (0.0, pango.VarMeta(0, 5))
|
||||
var_ui.an_int = (2, pango.VarMeta(0, 5))
|
||||
var_ui.a_double_log = (3.0, pango.VarMeta(1, 1e4, logscale=True))
|
||||
var_ui.a_checkbox = (False, pango.VarMeta(toggle=True))
|
||||
var_ui.an_int_no_input = 2
|
||||
var_ui.a_str = "sss"
|
||||
|
||||
ctrl = -96
|
||||
pango.RegisterKeyPressCallback(ctrl + ord("a"), a_callback)
|
||||
|
||||
while not pango.ShouldQuit():
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||
|
||||
if var_ui.a_checkbox:
|
||||
var_ui.an_int = var_ui.a_double
|
||||
|
||||
var_ui.an_int_no_input = var_ui.an_int
|
||||
|
||||
d_cam.Activate(s_cam)
|
||||
pango.glDrawColouredCube()
|
||||
pango.FinishFrame()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
36
thirdparty/Pangolin/pyexamples/SimplePlot.py
vendored
Executable file
36
thirdparty/Pangolin/pyexamples/SimplePlot.py
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
sys.path.append('../build/src')
|
||||
|
||||
from OpenGL.GL import *
|
||||
import pypangolin as pango
|
||||
import math
|
||||
|
||||
def main():
|
||||
win = pango.CreateWindowAndBind("main py_pangolin", 640, 480)
|
||||
log = pango.DataLog()
|
||||
log.SetLabels(["sin(t)", "cos(t)", "sin(t)+cos(t)"])
|
||||
|
||||
t=0;
|
||||
tinc=0.01
|
||||
|
||||
plotter = pango.Plotter(log,0,4*math.pi/tinc,-2,2,math.pi/(4*tinc),0.5);
|
||||
plotter.Track("$i")
|
||||
plotter.AddMarker(pango.Marker.Vertical, -1000, pango.Marker.LessThan, pango.Colour.Blue().WithAlpha(0.2))
|
||||
plotter.AddMarker(pango.Marker.Horizontal, 100, pango.Marker.GreaterThan, pango.Colour.Red().WithAlpha(0.2))
|
||||
plotter.AddMarker(pango.Marker.Horizontal, 10, pango.Marker.Equal, pango.Colour.Green().WithAlpha(0.2))
|
||||
plotter.SetBounds(pango.Attach(0), pango.Attach(1),
|
||||
pango.Attach(0), pango.Attach(1))
|
||||
|
||||
pango.DisplayBase().AddDisplay(plotter)
|
||||
|
||||
while not pango.ShouldQuit():
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||
|
||||
log.Log(math.sin(t), math.cos(t), math.sin(t)+math.cos(t))
|
||||
t+=tinc
|
||||
|
||||
pango.FinishFrame()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
58
thirdparty/Pangolin/pyexamples/SimpleVideo.py
vendored
Executable file
58
thirdparty/Pangolin/pyexamples/SimpleVideo.py
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import numpy as np
|
||||
import time
|
||||
import json
|
||||
|
||||
# If this example doesn't work, it's probably because this path is wrong...
|
||||
sys.path.append('../build/src')
|
||||
|
||||
import pypangolin as pango
|
||||
|
||||
def main(flags):
|
||||
vid_uri = flags.pango
|
||||
vout_uri = flags.pangoOut
|
||||
|
||||
vid = pango.VideoInput(vid_uri)
|
||||
vout = pango.VideoOutput(vout_uri) if vout_uri else None
|
||||
|
||||
device_properties = vid.DeviceProperties()
|
||||
|
||||
# print metadata
|
||||
print("Opened video uri: '{}' with {} x {} dimensions".format( vid_uri,vid.Width(),vid.Height()))
|
||||
|
||||
# user specified initial frame
|
||||
vid.Seek(flags.startFrame)
|
||||
|
||||
# show each frame
|
||||
streamsBitDepth = vid.GetStreamsBitDepth()
|
||||
|
||||
for frame in vid:
|
||||
if vout:
|
||||
vout.WriteStreams(frame, streamsBitDepth, vid.FrameProperties(), device_properties);
|
||||
|
||||
# frame is a list of Images! One per stream
|
||||
# process(frame)
|
||||
|
||||
# printing
|
||||
sys.stdout.write('\rframe: {} / {}'.format(vid.GetCurrentFrameId(), vid.GetTotalFrames()))
|
||||
|
||||
print('\nDONE')
|
||||
|
||||
if __name__ == "__main__":
|
||||
# input flags
|
||||
parser = argparse.ArgumentParser('Read a .pango file frame by frame. Optionally stream to another video output.')
|
||||
parser.add_argument(
|
||||
'--pango', type=str,
|
||||
help='path to the input pango file.')
|
||||
parser.add_argument(
|
||||
'--startFrame', type=int, default=0,
|
||||
help='index of the start frame (inclusive)')
|
||||
parser.add_argument(
|
||||
'--pangoOut', type=str, default=None,
|
||||
help='path to the output pango file.')
|
||||
|
||||
# main function
|
||||
main(parser.parse_args())
|
||||
Reference in New Issue
Block a user