Sync chart with video playing? - python

I have a project which shows a chart with matplotlib and I need to sync the bars showing in a certain time based on some specific frames of a video.
How to sync them in reverse, too?
Until now I created dynamic bars that change in a specific time, and just open the video with a window, but they’re not effectively synchronized.

Related

python draggable tasks by ressource gantt

I have to build an application where I have tasks assigned to resources.
I would need to design a kind of Gantt chart where I have a row for each resources (approximately 200) and on each row there are several tasks assigned to the corresponding resource (up to 30 in a month).
I have to move the tasks among the resources in order to reallocate the corresponding task from one resource to an other by using drag and drop.
Also there is an another list of tasks which have not been allocated to a resource, I have to allocate them by drag and drop to a chosen resource.
There is no relationship between the tasks, just simple "boxes" put to the right position (right row and datetime column).
Altogether I have to display around 4000 tasks in a month and being able to move them along, so the performance must be fine.
All the solutions I've seen (matplotlib, python-gantt, etc.) are (as I've understood) just static display of tasks, no dynamic drag and drop interaction.
Are there any ready to use (possible open source) gantt chart type of solution for python I could use for my project?

Is it possible to switch two regions of the screen (Windows)?

I am a developer with low vision. Right now I am working on a personal project to improve my ability to make use of large screens and play video games.
Sometimes when using a widescreen monitor up close (within 4-8 inches) I have trouble reading the screen along the edges. This is particularly troublesome when trying to read the clock or use a mini map in a game. It would be nice if I could temporarily switch the edge of the screen with the center.
I have successfully been able to move parts of the screen using screen captures and PyQt (screenshot).
This is nice but I would like to do this while preserving my ability to click or select text in the region. This seems like a rather involved process If I want to use PyQt and somehow pass clicks through to the screen.
For example:
Is there a lower level api that would allow me to tinker with the screen's output? Any suggestions are welcome!
Thanks

Raspberry Pi Python Graph continually updating

I'm using a raspberry pi currently for a engineering project, and am collecting data using the GPIO pins from various sensors. Id like to display this data on a graph. I've used matplotlib to get a graph to show, but for the program to continue you need to close the graph window. I've researched, but can't seem to find a way to make the graph stay open, and have it continually updated with the program running in the background. Is there a way to do this? Or should I try creating a HTML file with a graph in it and have the program open that?
Thanks for any help!
You can use the Plotly Python API to log and stream data to a graph in your browser from your RasPi. You can fork the code from GitHub to setup an online graph like this. The example here is temperature.
Once you've generated your graph, you can embed it as an iframe with this snippet:
<iframe id="igraph" src="https://plot.ly/~abhishek.mitra.963/1/400/250/"
width="400" height="250" seamless="seamless" scrolling="no"></iframe>
You'll want to swap in your URL in the snippet. You can edit the width and height in the URL string and fields to change how it looks. Here's how it looks:
(Full disclosure: I'm on team Plotly).
You could show the Graph in another Thread by using the module thread or the module threading (which is an object oriented and more powerful alternative). For more infos on these module have a look the python documentation for thread or threading.

What signals should I catch when scrolling in a Gtk ScrolledWindow?

I'm developing a python plugin for Rhythmbox - this contains a GtkScrolledWindow with a child which is a GtkIconView. The IconView is fed from a Gtk.TreeModel.
It looks like this:
Currently - and somewhat inefficient, every icon is drawn for every row in the tree-model - each icon is a GdkPixbuf from a file. If you have thousands of rows, it can take quite a while for the whole iconview to be fully updated with every picture icon.
What I am trying to achieve is to only update the icons that are in the current drawing area - when the user scrolls and releases the scrollbar (or navigates via the keyboard), the icons in the new drawing area should be updated with relevant pictures.
N.B. - the tree-model would be fully populated at this point - only the icons would not have been loaded.
This is not really my area of expertise - I'm looking for pointers for the best approach I should use to achieve the above.
Specifically - which Gtk+3 drawing-area signal (or signals) can be exposed (Gtk.ScrolledWindow / Gtk.IconView ?) to write python code to calculate what icons should be updated?
You should profile you application to see what takes time.
Is that loading the images ? If it is, then loading a default image and adding it everywhere in your view would be quick enough, as you'd load only one image. You'd then load and update the images on-demand using idle_add, based on the images that should appear in the viewport.
If what takes times is adding the images to the model, then you'd need to do the adding on-demand, by checking what is visible on the viewport in your idle_add callback.
If both are slow, you'd need a mix of both solutions: loading and adding on-demand.
Think also about the proxy design pattern that can be useful to create a fake cover object that will load in the background, and contain the loading policy.
For the signals, your GtkIconView widget implements GtkScrollable, which explains how to implement scrolling. You'd set your vertical adjustment and check when it has changed by connecting to its value-changed signal. This would mean the user scrolled up or down, and you'd need to fire up a timer with timeout_add. If after a short timeout (between 0.5 and 1s I think, but needs testing), the adjustment hasn't changed, this means the user stopped scrolling, and you can update what is displayed. Otherwise, it would be updated during the scrolling, slowing everything down. You then just need to figure out how to find which items appear in the viewport, to update their cover.
I've never done this before though, but I know GTK a bit and just tried to figure out how it would be done, so read that with a bit of caution. Anyway, the answer to reactivity is "on-demand".
But on the other hand if you have to scroll completely down, you would have to wait for every page to be build. So i guess you should better consider the idle_add function of the event loop.
This way your screen doesn't lock up and your pc doesn't have to wait for the user to load the view page for page. Win-Win for you and your application. ;-)

Interactive movie / video processing with PyQT / OpenCV

I am starting out on a project in which I need to build a customized annotation tool for movies and video. Some person (not technically minded) will need to pop open a GUI that I create, open either a video file or a directory of frames that result from chopping up a video file, and then use a window (much like QuickTime or VLC player, etc., i.e. a video window with a simple slider bar allowing the user to move back and forth at will). In this window, the user will be able to click on interesting points, give them semantic labels and meta-data (such as whether or not the point is occluded by something else in the picture), and then basically "press go" and start a tracker. The tracker will follow the points, frame by frame and the user can press the space bar or something to move forward and backward. The idea is to allow the human to intervene any time the tracker gets confused, but hopefully the tracker works well enough that humans don't have to hand-label every frame in an entire multi-thousand frame video sequence.
I am planning to do this all in Python, (a) because it is the language I know best for non-trivial programming, (b) I have easy access to both OpenCV Python (for image processing algorithms) and PyQt which seems to have a powerful enough GUI toolbox for what I want to do and (c) some other aspects of this same project are being developed by other programmers to work in Python and with MySQL databases. Python just seems like the natural choice to streamline it all together.
I am experienced using computer vision algorithms for the tracking, and I am reasonably sure that I can figure out simple PyQt GUI devices for making points clickable, buttons, entering simple text data, etc. However, the part I am having trouble understanding is how to actually construct my own video window with a slider bar that either moves ahead according to a frame's number or else is actually manipulating a video file. Can I leverage other movie players like VLC from within PyQt when programming in Python? Any suggestions or links that describe similar movie/video editing GUIs and how to develop them at home would be greatly appreciated.
Qt(PyQt) has a good multimedia support via Phonon module. You can easily use that module to achieve Video window, it can provide an easy-to-use video player and you can get playing position etc.

Categories