-
Notifications
You must be signed in to change notification settings - Fork 8
GLPlot.jl and OpenCV.jl interface possibilties? #18
Comments
Well, my mean goal would be, to have Computer Vision running completely on the GPU, allowing for great real time possibilities. But for that quite a bit of work is required, also for the OpenCL package (cc @vchuravy) |
Sounds great! I assume that combining all these so that they can be accessed through a single abstract type will be a slightly longer term goal. . . By the sounds of it you will develop your own independent access to OpenCV directly? It is trivial to add the support for OpenGL textures in OpenCV - this is documented. The bigger challenge is to pass the Textures to a UMat or GpuMat (CUDA) -- I have found this to be difficult in OSX because of the complications with compiling OpenCV with CUDA (also depending hardware, etc), so I am also looking into the OpenCL alternative. My main priority now is improving real-time object detection and tracking through OpenCV - rather than the visualization and plotting, which as you say is better suited for OpenGL and others. Currently, I am working on a tracking method that uses principal skeleton extraction (focused on zebrafish larvae). The main effort is in how to speed up new algorithms for the tracking itself in C++/Julia, and clearly having great visualization and plotting will be an important complement. |
Yes, I'd just add a glplot(::cvMat) function, which just takes the memory and displays it like a normal image for now... |
From reading the OpenCV Q&A forum, I think the first 2 points in your proposal are likely not to be considered I will focus on customizing OpenCV.jl for real-time tracking and object detection using OpenCL and CUDA if possible. Perhaps once this is working well we can see how our efforts can be combined/complemented? |
Oh, I guess I didn't phrase that right... |
Seeing this thread it does appear that there are ongoing discussions about how to get smooth conversion/handling of UMat between CPU/GPU, especially when this needs to be dynamic . . . |
I think this is somehow doable... And it seems that for OpenGL interop with CUDA they are already implementing the basics:
I still don't know how to initialize a umat with an opencl buffer, but from reading the source I infer, that its somewhat possible, if you know OpenCV well enough! |
Thanks for the update. I have already wrapped |
I actually hope to build GUIs with my GL packages at some point ;) That's 2015-01-07 0:51 GMT+01:00 Maximiliano Suster [email protected]:
|
Yes, but its not only the GUI windows (rapid drawing) that needs support, also the entire "signal/slots" event handling, multithreading (concurrent) GUIs and image processing that must be supported as smoothly as possible (without involving a lot of dependencies), I have investigated very closely many of the existing GUI interfaces in C++ and how they are typically used, and it seems to me that every time you need to re-invent the wheel. This appears very wasteful and it would be a lot wiser to either have something like Qt or a native Julia solution like Qt that supports most applications . . . |
You're right, but I'd really like to have a GUI library written in a sane 2015-01-07 2:15 GMT+01:00 Maximiliano Suster [email protected]:
|
Good luck! I will work on wrapping Qt. Together with multithreading support from C++ boost, we should be able to run high-performance image acquistion/display through Qt. What I am really looking forward to with the Julia interface is that the algorithms and data analysis of events can then be done with the high peformance algorithms in Julia (machine learning, K-clustering) in an independent thread (which does not have to be real-time) and hopefully sometime in the future perhaps we can also use cloud computing as these guys have done with Thunder with Python/Amazon cloud services. |
Thanks =) Who knows, maybe I'll end up using your QT wrapper... If I am Thunder looks awesome! 2015-01-07 2:38 GMT+01:00 Maximiliano Suster [email protected]:
|
Hey I was just thinking, wouldn't it be smart, if we at least try to use a similar designed pipeline? Common types and such? Than we can reuse code and probably simply exchange the front-end, if one comes out better than the other... I'm pretty open to any design choice, I "just" want to have something easy to extend, fast and flexible in the end ;) |
Sure, I have been open and eager to have more interaction in the development of GUI and Computer Vision support for Julia. What do you have in mind for the vector math/color library on your end? I am not as familiar with the integration of sliders and callbacks in OpenGL. Are you using GLUT for handling callbacks? If so, isnt´t the support for callbacks pretty limited, especially when compared to Qt? Can you explain the overview of your proposed approach for capture/processing and viewing and integration with event handling (i.e., flexible callbacks) with OpenGL? I think we need to start by discussion and clarifying the "design" principle - once we have that I believe that we could collaborate productively. . . |
Types: #D3 => generic vector with 3 dimensions
immutable RGB{T} <: FixedSizeWrapper{D3{T}}
data::D3{T}
end
# Define accessors to the vector
# Red = inspired by SIUnits.jl
# abstract Dimension{T} <: Number
# Red{T <: FloatingPoint} <: Dimension{T}
@type_accessors RGB (Red => 1, Green => 2, Blue => 3)
RGB{T}(a::T,b::T,c::T) = RGB(D3{T}(a,b,c))
RGB{T}(i::T) = RGB(D3{T}(i,i,i))
abstract GeometricVector{T} <: FixedSizeWrapper{T}
@type_accessors GeometricVector (X => 1, Y => 2, Z => 3, W => 4)
immutable Point{T <: FixedSizeVector} <: GeometricVector{T}
data::T
end
immutable Normal{T <: FixedSizeVector} <: GeometricVector{T}
data::T
end
immutable Vertex{T <: FixedSizeVector} <: GeometricVector{T}
data::T
end
const white = RGB(1f0)
const img = [white for i=1:100, j=1:100]
redchannel = img[Red] # Array{Red{Float32},2}
redchannel = img[1:10, 1:10, Red:Green] # Array{D2{Red{Float32}, Green{Float32}},2}
#Conversion to other spaces, without any overhead:
in_geometric_colorspace = convert(Point, img) # Array{Point{D3{Float32}},2}
in_geometric_colorspace[X] # Array{X{Float32}, 2}
#Set single color value in the matrix
img[1, 1, Red] = 0.77f0
const p = Point(v)
p[X] # X{Float32}(1.0f0)
p[1] # 1.0f0
p+p; normalize(p); p/1f0; #Basic arithmetic operations are defined Biggest advantage of a system like this is, that I always know how to visualize the values. immutable TranslationMatrix{T <: FixedSizeMatrix} <: FixedSizeWrapper{T}
data::T
end
immutable RotationMatrix{T <: FixedSizeMatrix} <: FixedSizeWrapper{T}
data::T
end
immutable ViewMatrix{T <: FixedSizeMatrix} <: FixedSizeWrapper{T}
data::T
end I'm not sure if I'll go through with this though... Probably I'll just have one matrix type. So far I'm using GLFW.jl together with Reactive.jl for the event handling. GLFW.jl is a very nice library, Reactive is sort of nice, but slow and with just a small feature set. image = lift(fps(30.0)) do fpsdiff # sample video source at 30 frames
VideoIO.read(camera)
end
edges = lift(canny, image)
gaussed = lift(gaussian, image)
whatnot = lift( image) do img
#fancy stuff
end
image_tiles = lift(vcat, image, edges, gaussed, whatnot) # turn into array of images
lift(visualize, image_tiles) # have a two by two grid view of the images Reactive will create a lot of copies with every new value, which is quite unacceptable... You can look at https://github.com/SimonDanisch/Romeo.jl/blob/master/test/runtests.jl for an example of how I build GUIs at the moment. |
First, thanks for sharing your progress on this! You have been definitely putting in some effort into your approach. I like very much the idea of doing something with the "native" julia packages. Do you need to redefine
The other big issue I take into consideration right at the beginning is how will we be able to parallelize processes (display vs processing), because there is no way you can aim for high speed real-time (>200 fps) computer vision without running things in parallel. This should be considered in the design of the application just as Qt has QtThread and concurrency support. |
I ran your WARNING: (convert{T})(p::Type{Ptr{T}},a::Array) is deprecated, use convert(p,pointer(a)) instead.
in depwarn at ./deprecated.jl:40 My first impression (not a criticism:) is that it is very slow and I have no idea yet what to suggest to speed it up. I will have a look at the code and see whether I understand it well enough to make useful suggestions. . . I do suspect there is something about the function |
What part is slow? The loading is incredibly slow, but the rest should be 2015-01-08 23:47 GMT+01:00 Maximiliano Suster [email protected]:
|
Now, with this tree and Julias JIT you can do some crazy things, like actually compiling the whole tree with inlined functions without callbacks, making the event tree really fast. Also you can identify branches which can be executed in parallel, which could be used for some automated multi-threading. Excuse me if things don't make sense, I'm a little bit in a hurry right now. Thanks for any criticisms/ideas and contributions! :) |
As I said, your
I can not agree fully with this. I have seen how complicated things can get in Q: With the Julias JIT lift tree approach, can you change the lift tree instructions and GUI at runtime? My rambling here: I envision (in an ideal word) a lisp-like |
Short reply: |
Sounds good, will be interesting to see how |
Definitely! By the, I also use style to select a preset of keyword On Fri, 9 Jan 2015 01:22 Maximiliano Suster [email protected]
|
I just saw, that Romeo prints a lot of warnings while running... Could this be why it was slow for you? |
Yes, see comment above. |
Okay, this should be fixed then. I thought you meant that this was a one off warning, and not firing the whole time (which was the case on ubuntu so far). |
@SimonDanisch.
I figure it might be interesting to exchange some ideas on how OpenGL textures could be processed in OpenCV, and discuss possible interfaces for advanced image processing and graphics. In my first version of
OpenCV.jl
, I have used OSX Cocoa first to display the images but now I also managed to get Qt 5.3 + OpenGL working as well. It seems that there are multiple options available.I had a look at your
GLPlot
package and the supporting packages (GLWindow, etc). My first general impression is that it would be good to have the option to extract the minimum necessary support from these packages to interface with OpenCV rather than calling everything at once. I am not too keen on slowing down the whole thing, especially as this is a serious caveat with Julia right now. What is it that you want to get out of the OpenCV framework? On my side, I am particularly interested in using image display and processing tools for high-speed real-time tracking and object recognition.The text was updated successfully, but these errors were encountered: