summaryrefslogtreecommitdiff
path: root/html/examples/capture.lua
diff options
context:
space:
mode:
authorscuri <scuri>2009-06-26 17:14:56 +0000
committerscuri <scuri>2009-06-26 17:14:56 +0000
commit193cd3427108bd127e09f391f7fe51f6b62590e9 (patch)
tree7dfd83dec634c15f87f578266f6fdb0df046613a /html/examples/capture.lua
parent734afa90c3dda1232e9490d08346be4f2ffefec1 (diff)
*** empty log message ***
Diffstat (limited to 'html/examples/capture.lua')
-rw-r--r--html/examples/capture.lua63
1 files changed, 63 insertions, 0 deletions
diff --git a/html/examples/capture.lua b/html/examples/capture.lua
new file mode 100644
index 0000000..491518a
--- /dev/null
+++ b/html/examples/capture.lua
@@ -0,0 +1,63 @@
+require"imlua"
+require"imlua_capture"
+
+im.VideoCaptureReloadDevices()
+
+print("--- Devices ---")
+local n = im.VideoCaptureDeviceCount()
+
+for i = 0, n - 1 do
+ desc = im.VideoCaptureDeviceDesc(i)
+ print(desc)
+end
+
+local vc = im.VideoCaptureCreate()
+print("connect: ", vc:Connect(0))
+print()
+
+print("--- Dialogs ---")
+
+local dc = vc:DialogCount()
+for i = 0, dc - 1 do
+ desc = vc:DialogDesc(i)
+ print(i, desc)
+ vc:ShowDialog(i)
+end
+print()
+
+
+print("--- Formats ---")
+
+local fc = vc:FormatCount()
+for i = 0, fc - 1 do
+ local success, width, height, desc = vc:GetFormat(i)
+ print(i, string.format("%dx%d", width, height), desc)
+end
+print()
+
+print("--- Image Size ---")
+local width, height = vc:GetImageSize()
+print(width, height)
+print()
+
+print("--- Attributes ---")
+attribs = vc:GetAttributeList()
+for i, name in ipairs(attribs) do
+ local error, percent = vc:GetAttribute(name)
+ if error == 0 then percent = "get error" end
+ print(i, name, percent)
+end
+--vc:SetAttribute("FlipVertical", 1)
+--vc:SetAttribute("FlipHorizontal", 1)
+print()
+
+print("--- Capture ---")
+local image = im.ImageCreate(width, height, im.RGB, im.BYTE)
+local res = vc:Live(1)
+if (res > 0) then
+ print("grabbing frame")
+ print(vc:Frame(image, 3000))
+end
+image:Save("capture.jpg", "JPEG")
+
+vc:Disconnect()