Functions for the Following GIMP Functionality - gimp

I'm making my first foray into GIMP scripting (hopefully in Python, but I'm open to Scheme too). I know exactly the steps I want to take using the GIMP UI, and I'm trying to determine which, if any, of the steps can be executed from a script, since the documentation I found suggested that not all functionality can be accessed in this way. Looking at the documentation helped with some, but not all, of what I'm looking for, so I'm hoping for a pointer as to which of the following functionality I can access from Python, and what function I will need, since my googling as come up short.
new layer
new layer from visible
duplicate layer
changing mode to overlay/grain extract/grain merge
gaussian blur
merge layer down
desaturate (lightness)
adjust color curves
filling a transparent layer with the paper pattern
adjust opacity

Open the Python console (Filters>Python-fu>Console).
Hit the Browse... button
Enter what you look for in the top bar on the left (for instance "desaturate")
Select the call in the list below the search filter and see the doc on the right
This includes any callable installed script/plugin (if the authors did their homework). "Apply" copies a call template in the Python console.
You can do more in Python than in Scheme.
The doc for the Python classes is here. The more frequent API calls have corresponding methods/attributes.
If you are on Windows, some tricks to ease your debugging here.
There is not always a direct mapping between UI actions and the API. Some UI actions may correspond to several API calls.
In Gimp 2.10, the GEGL filters aren't callable from Python (at least via the regular Gimp API), unless they replace an existing 2.8 filter (like the Gaussian blur).

Related

Is there a programmatic way to see what graphics API a game is using?

For games like DOTA 2 which can be run with different graphics API's such as DX9, DX11, Vulkan, I have not been able to come up with a viable solution to checking which of the API's its currently using. I want to do this to correctly inject a dll in order to display images over the game.
I have looked into manually checking what dll's the games have loaded,
this tool for example: https://learn.microsoft.com/en-us/sysinternals/downloads/listdlls
however, in the case of DOTA, it loads in both d3d9.dll and d3d11.dll libraries if none is specified in launch options on steam. Anyone have any other ideas as to how to determine the correct graphics API used?
In Vulkan, a clean way would be to implement a Vulkan Layer doing the overlay. It is slightly cleaner than outright injecting dlls. And it could work on multiple platforms.
In DirectX, screencap software typically does this. Some software adds FPS counter and such overlays. There seems to be open source with similar goals e.g. here: https://github.com/GPUOpen-Tools/OCAT. I believe conventionally the method is to intercept (i.e. "hook" in win32 api terminology) all the appropriate API calls.
As for simple detection, if it calls D3D12CreateDevice then it likely is Direct3D 12. But then again the app could create devices for all the APIs too and proceed not to use them. But I think the API detection is not particularly important for you if you only want to make an overlay; as long as you just intercept all the present calls and draw your stuff on top of it.

How to run Noise reduction filter from plug-in?

I want to write a plug-in, that besides other things, apply Enhance/Noise reduction filter. But I found out that there is no similar procedure in the browser. And even no documentation for this filter, which is strange.
So, does anybody knows how to call Noise reduction filter from a plugin? And why some of the filters not documented and not present in procedures?
As its icon indicates, this is a GEGL operation, and unfortunately these have currently no API for scripts.
To be more complete, and as far as I can tell:
No new API has been added for the new GEGL tools
However, for compatibility:
Functions that had an existing non-GEGL implementation have been converted to use the equivalent GEGL tool (for instance deinterlace and blur-gauss still are called plug-in-something in the API but you won't find them listed in pluginrc)
Some plugins that are no longer shown in the UI still have the plugin code to make them callable by legacy scripts (plug-in-sharpen for instance)

Trackbar in rqt ros

I am trying to interface ROS and open cv. I was able to threshold the video stream and display the output in rqt. Now I want to adjust the threshold range by creating a track bar in rqt. How could I implement it.
The best way in terms of integration and looks would be to create your own rqt plugin (tutorial). However you'd need to find some way to notify your node about any changes (e.g. via a service call).
Much easier and faster, and usually sufficient, is to re-use existing functionality. In this case, take a look at dynamic_reconfigure. This allows you to change parameters on the fly, you only need to define the configuration and register a callback in your code (tutorials). The GUI integrates into rqt.

Import/export or store/restore xShapes in LibreOffice/OpenOffice Draw via API

I want – as the title says – extract programmatically a shape from a Draw document through the api interface. Beside I want to import such a shape into a document as well.
I saw some predefined shapes in XML form and the document is stored as XML structure as well. Is there a known way to anybody out there to allow the storage and load of one shape?
What is this good for?
I want to, for example, enable the programmatic deletion of objects. But to enable the undo/redo functionalities I need to “store” the deleted shape. Beyond that this would allow me to add user-defined objects programmatically, e.g. arrow heads, UML structures or unicorns.
Thanks in advance for any ideas,
J
P.S.: I work with LibreOffice Version: 5.2.1.2 . Access the interface through C# (so java and C++ would do it as well) but any ideas are welcome.
I'm not entirely sure what you are trying to do, but here are some ideas:
Instead of deleting an XShape, you could use the dispatcher to Cut it. That will store it in the clipboard, so if it needs to be added back then the dispatcher can Paste it, as long as no other copy or cut was performed.
To create a shape, see the example at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Drawings/Shapes. This code will look different depending on what kind of shape it is. It sounds like you are asking for one code listing that will programmatically create any type of shape, but I do not think it is that easy.
Instead of using the UNO API, you could programmatically modify the XML files, which may make it easier to store and work with any shape. Be sure to use an XML parsing library, not just regular expressions.

How can I process a -dynamic- videostream and find the (relative) location of a "match" in that videostream?

As the question states: how is it possible to process some dynamic videostream? By saying dynamic, i actually mean I would like to just process stuff on my screen. So the imagearray should be some sort of "continuous screenshot".
I'd like to process the video / images based on certain patterns. How would I go about this?
It would be perfect if there already was (and there probably is) existing components. I need to be able to use the location of the matches (or partial matches). A .NET component for the different requirements could also be useful I guess...
You will probably need to read up on Computer Visual before you attempt this. There is nothing really special about video that seperates it from still imgaes. The process you might want to look at is:
Acquire the data
Split the data into individual frames
Remove noise (Use a Gaussian filter)
Segment the image into the sections you want
Remove the connected components of the image
Find a way to quantize the image for comparison
Store/match the components to a database of previously found components
With this database/datastore you'll have information on matches later in the database. Do what you like with it.
As far as software goes:
Most of these algorithms are not too difficult. You can write them yourself. They do take a bit of work though.
OpenCV does a lot of the basic stuff, but it won't do everything for you
Java: JAI, JHLabs [for filters], Various other 3rd party libraries
C#: AForge.net

Resources