Display opencv frames in a window with button and text control - qt

I'd like to ask you some information about a problem which i want to solve.
At the moment, I have two opencv applications:
application A: where i track an object with two types of algorithms and each time i save a frame in an image file and i control the application behavior with some commands which i write in the shell
application B: where i have a loop which reads every time the image file and display it
So, I launch these two applications together in order to track the object with appA and to display results with appB which reads everytime the frames saved by appA in the hard disk.
I want to integrate application B in application A in order to show a window (like this: http://lnx.mangaitalia.net/window.jpg) in order to have a loop which shows image in the first area and to use buttons in order to give commands which at the moment i write in the shell.
Do you think it's possible to display the frames in an area with Qt or opengl or wxwidgets?
Which solution is the better and the easier to apply?
At the moment, my application B is very simple:
while(1)
{
Mat img=imread("result.jpg",1);
if(!img.empty())
imshow("HOG",img);
if(waitKey(200)==27) break;
}
I want to show these frames in a window which has also some buttons.
In particular, as you can see in the attached image in this post, i want to create a window divided in two parts: the first one which display the frames captured from opencv camera and the second part (or area) which has some buttons (B1, B2, B3..) which the user can press in order to control the application behavior.
(At the moment, i use a switch/case in appA to trap the keyboard keys)
There is some example based on a template similar to what i'd like to do?
(like the jpg image i've told before: http://lnx.mangaitalia.net/window.jpg)

I propose that you just use the inbuilt GUI in OpenCV: highgui. It has keyboard/mouse IO, window control with a message loop, buttons, sliders etc. And there is no need to do any conversions of the cv images to show them.
Have a look at: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut3.html (It is written for old IplImage style CV, but the C++ interface is almost the same, use cv::imshow to draw images)
Also, here is the documentation for the C++ style interface.
There is also the possibility to convert your CV images to QImage in Qt and do it that way... you should be able to find solutions for that on Google.

There are some examples out there for implimenting this.
see http://larryo.org/work/information/wxopencv/index.html
Basically what you want to do is:
capture a frame from your camera
manipulate the image
use cvConvertImage to convert it into a format wxImage can read
draw this image on to a wxCanvas
For the GUI part of this, you would need to create a wxFrame or wxWindow, place some sizers and buttons at appropriate places.
So basically make a frame, put a sizer on the frame, then put a panel in the sizer.
next make a vertical sizer on the panel. First add a wxCanvas to the vertical sizer, then place a horizontal sizer in the vertical sizer. Now add 3 buttons to the horizontal sizer, and you have your panel.

Related

Java FX - Dividing a Node for multiple page printout

I been searching for post about multiple page printout on javafx. they say that for a node that is too big to fit on one page must be divided and pass each for printjob. the instruction given for that is too vague for me to understand.
Let say i have a TextArea with a list of hundreds of names which obviously would not fit in one page. How will i divide that into a multiple of nodes to pass each on the print method of PrintJob? (output to be printed on a letter size paper)
I have to admit that I have never done that myself but what I would try is the following: Assume you have a node which would cover two pages when printed as a whole. I would then set a clipping rectange on the top level node which covers the left page and then print it. After that I would set a new clipping rectangle wich covers the second page and transform the node so that the second page starts in the uppder left corner and then again print it. I think this could work but as I said before I have never done that before.

Create 2D bar code that contains back-tab

Is it possible, and if so how, do I create a 2D bar code using IPL, intermec programming language, that contains human readable text, TAB, and BACK-TAB. The goal is to print the bar code that can then be scanned on a different computer that we have no control over. The software running on the PC contains fields that would be populate based on the information contained in the bar code along with TAB, BACK-TAB, and SPACE. The goal is to print the bar code containing numerous information and keystrokes that will allow the users to simply scan the 2D bar code which will fill out all information on their workstation.
I have tried to emulate the shift-in, Tab, and shift-out but nothing seems to work.
I read several article that indicate I can do this, and several that indicate I cannot. Neither list clear reason why this will or will not work.

Qt5 QTreeView with custom model and large data very slow scrolling

I have custom data that I need to display in a QTreeView. I have derived my model from QAbstractTableModel, and made my own implementations of rowCount(), columnCount(), data(), and headerData(). The model has a local QList> to support it, and the data() function is defined to read the values out of that list of lists directly corresponding to the row and column received in the QModelIndex parameter. There are two issues I'm running into.
The first is that the load of a very large file is quite slow, which is understandable. The second is that the scroll action is painfully slow, which I am not really understanding. Turns out that if I pull the scroll handle down, the GUI hangs for about 20 seconds, and then pops back. If I pull the handle a greater distance down, the hang time increases accordingly. If I pull the handle all the way to the bottom of the scroll bar, after waiting for the application to become responsive again, I can pull the handle up and down and get much better response.
It seems to me that QTreeView is only asking for a small chunk of the available data, but when I have pulled the scroll handle all the way to the bottom of the scroll bar, once the application becomes responsive again, it has by that point read all the data.
Is there a way to program for a much more responsive experience with scrolling for large data? I don't mind a longer wait up front, so just something like forcing the view to read all data from the model up front would work.
I have also thought that I could go back to just deriving from QAbstractItemView and controlling how it requests and stores data, only allowing for storing the viewed data, plus a buffer of entries before and after the viewed data. That of course would mean I'd have to control the scroll bar, since the handle sizing would indicate a small amount of data, and I would like it to look to the user as it should for the size of data they are dealing with. Not really wanting to go there if I don't have to.
Two things:
Re-implement fetchMore() and canFetchMore() in your model. See this implementation example. Basically, the two functions allow lazy initialization of your data and should stop ui freezes.
Replace your usage of reset() and dataChanged() to use the insert and remove functionality. Right now, you are forcing the view to recalc which of 100,000 items to show.
use
treeview view;
view.setUniformRowHeights(true);
Then view do n't hangs.

3-state "expanded", "collapsed" and "semi-expanded" tree control

What I'm trying to do is have a 3 state tree expansion.
I have three different icons for "expand" "collapse" "semi-expanded" which I want to use to show a partially populated tree control with all nodes initialized to semi-expanded state and then on clicking the "semi-expanded" icon it gets data from server and populates the tree and open that branch with "expanded" icon.
I tried looking for it but couldn't find anything close to it except the 3-state checkbox but don't know how to use it on 3 state icon when tree would only maintain 2 states.
Thanks in advance.
I think what you are looking for is called a lazy-loading tree. There are lots of examples your can google for, but here is a great example.
As far as the visual part of your request goes (3 different icons to show that state of the branch or node) - you could easily handle that with a custom renderer, by looking at a flag on the node for it's load status.
Does that help?
A 3-State tree control is a bit uncommon and might therefore be a bit confusing; consider that even simple 3-state checkboxes are relatively rare and users may not be accustomed to them. Maybe that's why you didn't find such a tree control.
Thus, maybe you should consider using an alternate design that doesn't require 3-state controls.
For example, the node could start in collapsed node. If the user expands it, and there is no data yet, show a single sub node with the text "retrieving data..." (and a progress wheel or other progress indicator, if you can) and start data retrieval. When the data arrives, replace this sub node with the actual data.

Flex web application gets progressively slower and freezes

I have a Flex web application where I am visualizing data (for different countries) in the form of charts. The data is in the form of CSV files. There are individual files for individual charts i.e. one file has all data pertaining to one chart for all countries.
I have a left navigation menu that allows one to see data on a country by country basis. As I view more and more countries, the web application becomes progressively slower till it freezes completely. The problem goes away if I refresh the browser and empty the cache.
I am using the URLLoader class in flex to read the CSV data into a string and then I am parsing the string to generate the charts.
I realize this is happening because more and more data is somehow accumulating in the browser. Is there any way in Flex to rectify this? Any pointers/help would be appreciated.
Thanks
- Vinayak
Like #OXMO456 said before my, I would use the profiler to check this issue.
to refine my answer I would also say please make sure that you are following all of the rules for low memory in flex like
1. clearing out (removing) event listeners
2. nulling out static variables
and more like so.
I would use the "snapshot" feature of the profiler and see what is happening in minute 1 and then minute 2, the difference between the two of these is probably the source of your leak.

Resources