Been using opencv (mostly with python) for video capture/processing (Win10/Linux). Is there a way to create an output video stream that would appear as a valid source (like another camera) in videoconferencing software like zoom, skype, etc ? For now I just share the imshow() window, but it is slow/ineffective.
Related
I have some video streams I am able to get running in a VLC window and attach it to a QT widget - which is all fantastic.
Some of these video streams though are oriented differently than others, and I cannot figure out how to set the orientation - so some of my videos are displaying sideways.
Does anyone know how I can change this?
Not all of the vlc options are available (exposed) using vlc.py.
I am not aware of a method of orienting a video at the media level. This has to be done using the vlc.Instance.
This pre-supposes that you know the orientation required beforehand.
There are 2 options that I am familiar with:
--video-filter=rotate --rotate-angle=nnn.n
and
--video-filter=transform --transform-type=type
where type is one of {90,180,270,hflip,vflip,transpose,antitranspose}
code examples would be:
vlc.Instance('--no-xlib --quiet --video-filter=rotate --rotate-angle=90.0')
and
vlc.Instance('--no-xlib --quiet --video-filter=transform --transform-type=vflip')
I am currently working on a hobby project, which is video streaming from an IP camera (Giroptic 360) on RaspberryPi 3 board via RTSP.
I am particularly interested in its URL link used to connect to said camera:
rtsp://[IP address]:[Port]/PSIA/Streaming/channels/2?videoCodecType=H.264
I am wondering if there's such a thing as changing the streamed resolution directly from the URL link (by adding more parameters?) and if there's any more extra functionalities available through the URL link?
** I have tried changing the resolution via openCV's
cap.set(CAP_PROP_FRAME_WIDTH, 1000)
cap.set(CAP_PROP_FRAME_HEIGHT, 500)
But it still gave me the default 2048x1024 resolution.
No, you won't have anyway of commanding via the RSTP link using the opencv built in functions. These work at driver level and all the RTSP link provides is a place to pull frames from.
If you want to resize the images, you can do this after you grab the frame using OpenCV resize
If you want to size the stream itself, then you will need to recode the stream at the source i.e. go into the settings and change it. Although you may not have access to this if it is somebody elses stream, you dont have permissions etc.
I need to display the USB camera video of raspberry-pi in Wxpython with control buttons in it. I have managed to embed vlc in to Wxpython with control buttons (Got it from Google) to play existing video. Is there any way to stream the USB camera video in it?
Thanks in advance :)
If you've managed to embed VLC, you should just be able to point it at the v4l address for the webcam.
The v4l address should be along the lines of v4l:/dev/video0:size=640x480 (but it'll vary depending on your machine I guess). You may find it easier to use the standalone VLC client to get the address you need and then put it into your program.
This StackOverflow thread may be useful for later depending on what you're doing.
Background
I'm attempting to craft a simple video playback script for a small cinema that automates the playing of videos and control of the projector, sound and lighting systems. I have two video outputs, one goes to a monitor in the projection booth, and the other directly to the projector. I desire to play video (and only video) fullscreen to the projector while putting controls and a small (~1/4 screen) preview on the monitor. This will allow the projectionist to view the video being output and control the playback from the monitor in the booth while all the audience ever sees is the video output.
Problem
I am currently using Python to control VLC player (with libvlc Python bindings) to playback videos. I have everything working fine except that I can't figure out how to get a preview (direct copy) of the video being played fullscreen on the projector output into my GUI.
I have tried using the clone filter, but I cant get the cloned window to automagically appear full screen nor in my GUI. The clone filter seems like the logical choice but it seems to be VERY inflexible when it comes to specifying destination screens, fullscreen, etc. I must be able to open video windows full screen on the projector monitor. Professionalism is key and it would look bad if the projectionist had to drag a window over and double click on it when the movie started.
Currently Using:
Debian Linux
Python 2.7
wxPython
libvlc
I would like to continue using Python as I already have the code for controlling the projector, sound processor, lighting and curtain written and tested. I chose VLC because it really seems bulletproof when it comes to video playback but am not committed to it's continued use. I also chose wxWidgets for my GUI as a result of past experience but I am not stuck on that either.
This describes the direct solution and does not concentrate on any alternative or the overall design of your application.
As Your Application and VLC media player are separate processes, you will not be able to get what you want directly because there is no "shared memory" between those 2 applications. The best shot to "copy" the decoded frames from VLC will be to e.g. send a RAW Video .mts stream (ts is usually used for this kind of usecase) and send e.g. to udp://localhost:1234.
In your application, you will need to be able to receive the ts stream, "decode" it and display at the spot of interest.
For start, i would try if you are able to do this using 2 vlc players that you control manually. When you achieved that the first VLC streams to udp and outputs on the main display at the same time, and the other VLC player receives and plays the udp stream you can go on:
Find a player library that you can use directly in your wxpython application and check if it can receive the udp stream as well E.g.
https://wxpython.org/Phoenix/docs/html/wx.media.MediaCtrl.html
This player lib for example requires gstreamer as a base.
As a result, main display and the picture in your applicatoin might have a latency of some seconds. To come around this latency, the best way that i currently know is using WebRTC but this is a lot more complex setup than the above.
https://www.sipwise.org/news/technical/tv-over-webrt/
Sure in case you do some "encoding" for WebRTC or even for UDP, you would need to utilize some hardware encoder, e.g. Nvidia NVENC in order to be able to guarantee the needed resources are always there.
I have written a python application which generates output in graphviz DOT format. I convert the generated file into PNG using the external 'dot' utility and open the generated PNG in an image viewer to visualise the graph.
My application is an interactive command-line tool which allows few operations on the graph like changing the colours of edges based on the edge weights, deleting few nodes, etc. After these operations I generate the DOT file again and convert it to PNG for visualisation.
I came across xdot.py which allows me to embed the interactive viewer into my application. Now I do not have to go to the shell to generate the PNG every time.
I want to take this idea further and build a full-fledged GUI application on top of this. I have few questions regarding this:
Do I have to start from scratch (use wxPython or any other GUI framework)? Use a canvas to display the generated image and refresh it whenever there are operations performed on the graph.
Is there any other package which serves this purpose? I am looking for some package which can edit the graph and just provide me with the ability to bind my graph operations to the mouse events on the viewer.
Any other ideas? Greatly appreciate your inputs.
wxPython can display images very easily using wx.StaticBitmap. Here's a tutorial on the subject:
http://www.blog.pythonlibrary.org/2010/03/26/creating-a-simple-photo-viewer-with-wxpython/
You will probably need to do something like this:
img = wx.Image(filepath, wx.BITMAP_TYPE_ANY)
self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY,
wx.BitmapFromImage(img))
Then just refresh it whenever you update the image. Depending on your graphing needs, there is the matplotlib project which can be integrated into wxPython.
There is a project that use wxPython and pydot that you might find useful: http://code.google.com/p/pyflowuca/. I saw it mentioned here: http://pythonhaven.wordpress.com/2009/12/09/generating_graphs_with_pydot/