Are there existing python bindings to the FlyCapture API? - python

I'm trying to write some code using OpenCV. My sensor is from Point Grey Systems, and it uses the FlyCapture API to grab images. I'd like to grab those images and do some stuff in OpenCV to them, using Python. FlyCapture is all C/C++, so I'm firing up SWIG to create the bindings. Am I reinventing the wheel? Do python bindings for FlyCapture already exist somewhere that I don't know about?

As of FlyCapture 2.11 there are official Point Grey / FLIR python wrappers. I've used the python 2.7 so far.
the pyflycapture2 is still available as well...
just started using this wrapper last week pyflycapture2
working well so far with my FireFly MV USB

Here's a new Cython wrapper I started for the FlyCapture V1 API:
https://github.com/kbrafford/pyfly1
It also has some wx.Python demos showing it working and allowing you to assess performance.

If the Python language is your only restriction, you may use the wrappers for FlyCapture from the JavaCPP Presets by calling the appropriate functions via Jython.

Related

create golang bindings for a python module

I want to write golang bindings for an existing (third party) Python module.
The purpose is that I want to use the API that the Python module provides in Golang.
I already found golang bindings for Python's C API (go-python3 for py3 and go-python for py2), but I still haven't figured out how to translate a relatively complex Python module into Golang (i.e. how to deal with type safety in go for unsafe inputs and returns in python, etc).
What would be a good approach? Are there any pre-existing tools in that space? Are there any good examples for Golang bindings for Python code? (I couldn't find many tbh).
I want to use the API that the Python module provides in Golang.
Calling Python from Go is detailed recently in "Python and Go : Part I - gRPC" by Miki Tebeka.
You can see an example in ardanlabs/python-go/grpc
But, as shown in their next two articles, you can also:
compiled Go code to a shared library and used it from the Python interactive shell.
use a Python module that hides the low level details of working with a shared library and then package this code as a Python package.
Full example: ardanlabs/python-go/pyext.

Where in the TensorFlow source code do the Python bindings make the call to the core C++ libraries?

I have tried looking around the source code of the Python bindings and haven't been able to find where and how exactly the call is made (where Python connects to C++). I have also searched the web quite a bit, without luck, but it may be that I'm not using the right vocabulary for the search. Using trace in Python was also not as illuminating as I had hoped. Any nudge in the right direction is much appreciated.
Tensorflow used SWIG to do the bindings, but now they are moving into using pybind11.
Inside the code, you can search for PYBIND11_MODULE to find where the new bindings are made. The C++ code compiles to a library file, .so for example on Linux, which can be loaded directly by python.
To learn more about the new and the old method you can check this RFC.

how to control ImageJ from Python 3.4.2

I am trying to use Python 3.4.2 to control ImageJ
what I want to do is from python code , I want to sent orders to imageJ to analayse some images, detecting edges, contrast, noise etc
there is a similar question here
How to connect ImageJ to python?
but there is no answer, like "install this, and control the Find Edges button with this command"
I wonder how can I do that, can somebody help me
I have found this link, and this link, and they say that it is possible by using "import ij" but there is no ij library that I can use or install.
also ImageJ website states in "How can I call ImageJ from my software?" that "If your software is written in another language such as C or Python, there are many ways to integrate Java functionality. You must choose which one is best for your particular requirements." but there are no specifics
this Google webpage says that with "py4ij" I can control imagej with python "Py4IJ - Python for ImageJ - plugin and IDE that allows Python and Jython access to the ImageJ"
but I am not sure how to run it, Help
as an alternative to Imagej is Fiji but I am not sure if python can control it or I have to use Fiji, and Fiji tutorial
my last alternative is Using OpenCV for image processing but I actually need to use ImageJ or Fiji, so OpenCV is not a valid answer
thanks
EDIT
according to the first answer, it suggest to write a CellProfiler's RunImageJ module, but my question is should I have to install CellProfiler? from here, following the examples here and here and running the module
or should I follow the native Python idea from this link
in any case the first answer link talks about Jython, but I can not use Jython, the latest version of it is based on python2.7 and I am using 3.4, and there is no development for jython 3.x
help
Integration of Python with ImageJ was recently discussed on the new ImageJ forum; see the Python scripting thread.
While it focuses on calling native-code-wrapped Python modules such as NumPy from ImageJ, the reverse direction (calling ImageJ from Python) is also addressed by some of the solutions, particularly CellProfiler's RunImageJ module. As discussed there, a dedicated programmer could start there and champion a more general solution for the benefit of the community.
In general, this issue is discussed on the ImageJ wiki on the Python page, particularly the section on limitations.

How to use Python OpenCV functions in Sikuli

I'd like to use OpenCV functions, like Hough Transform and Corner Detection, in Sikuli.
I tried the OpenCV installation instructions for CPython on Sikuli and it's a no go.
I understand that Sikuli is Jython and this might be the hard way to do things. What are the easier alternatives?
I'd still like to use Sikuli & Python because the code I write just works; but maybe I'm hitting the limits of Sikuli.
You could use Automa as an alternative to Sikuli. It is a pure Python library (so you can use any other Python library with it) and its image search algorithms are fully compatible with Sikuli. In fact, it uses OpenCV's Python bindings itself, and thus ships with them.
Disclaimer: I'm one of Automa's developers.
Generally spoken: Python modules containing C-based code (which is the case for Python OpenCV) cannot be used in the Sikuli Script (Jython).
The integration of some OpenCV features in Sikuli is realized using the Java-To-C interface (JNI) and the usage of OpenCV features itself is coded in C++.
If you want to use OpenCV features not supported by Sikuli, then you either have to use the above mentioned JNI approach or use the Java implementation of OpenCV (javacv) (Java stuff can be used seamlessly from Jython scripts).
Another option of course is to implement the additional things in plain Python scripts using the Python/OpenCV and call these scripts via the C-Python interpreter in a subprocess.

Which version of python opencv should I go for?

Having successfully installed opencv 2.0 with python bindings I'm starting to run into trouble and before I go any further I wondered if I should change to another option. As ezod on this post says:
"As a caveat, as of the 2.0 release, the new Python bindings are incomplete: many functions I would consider rather important missing. Meanwhile, the SWIG bindings are nothing short of agonizing to work with. The ctypes-opencv bindings (3rd party project), as of version 0.8.0, do not support OpenCV 2.0."
So, should I soldier on with 2.0 or should I go for ctypes? What am I missing out on either way?
I'm using OSX, python 2.5 and wanting to do tracking in 2d of moving object and neither a python nor machine vision expert!
A late answer. If you do not have to depend on earlier versions, and want to use OpenCV with Python, choose the latest stable version. Today it is OpenCV 2.3.1.
The major benefit of OpenCV ≥ 2.3 for Python users: a new cv2 module in addition to the old (backwards compatible) cv module. New cv2 module is much more pythonic and doesn't require manual memory allocations for intermediate data structures. Old cv module is more like direct translation of the C++ API.
For example, compare the new Python cv2.findContours (OpenCV ≥ 2.3):
findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy
It requires only three parameters, and can handle all memory allocations automatically, returns only the final result. Just one line of the user code.
Vs. the old cv.FindContours:
FindContours(image, storage [, mode [, method [, offset]]]) -> None
It requires the user to explicitly allocate "storage" before the call (+ 1 or 2 lines of code). It doesn't return the result, instead it saves it in the allocated storage (it works like a linked list, and the user has to write some loop to actually extract the data out of storage). Overall, more low-level, and more like C++ than Python. At least 4-5 lines of code in the common use case, instead of just one line with new cv2 module.
I'm using a self-compiled OpenCV 2.0 and it's built-in python binding. Up to now I was missing 2 or 3 functions (e.g. FindFundamentalMat). If you get the source code of OpenCV you find a text file interfaces/python/api that defines the parameter and return types for each OpenCV function that is available from Python. Upon recompilation an automatic generator will parse this file and build the python extension. For all the cases I've been through I found that adding an appropriate definition to the api for the functions I needed, then recompiling opencv, worked quite well.
I'd recommend you use the official Python bindings to OpenCV 2.1 which as far as I've seen has feature parity with the C++ libraries. Most of them have either a pythonic wrapper, or a direct translation from the C++ version.
Python's OpenCV documentation isn't as complete as C++'s, but if you feel that the language advantages for prototyping are worth it, you'll be able to understand the Python usage from the C++ documentation.
Beware that much of the existing example code you'll find is from the previous versions and are incompatible (for example now everything resides under the cv package), but it's not hard to figure out how update it.

Categories