Can a progressBar be implemented in an OpenCV application? 开发者_开发知识库Maybe on top of an image?
I am unaware of any built in progressBar class but you can probably emulate one or write your own by drawing two rectangles on top of each other. One representing the full range and the other representing the progress.
If you want to use only OpenCV, what I use is to multiply a number between 0 and 1 to an image open in a window. i.e: if you are using the new C++ Opencv:
Mat A=...some image that show for example the text "DONE" or your dog or cat :P
double alpha=0;
int N=100;//steps
for(int i=1;1<N;i++)
{
// some process...
alpha=i/N;
A=A*alpha;// and alpha is a scalar
// if you are using the old C Opencv use cvConvertScale
//then show A
imshow("Progress Image...",A)
waitKey(666);
}
The effect is very nice in my opinion, better than a simple progress Bar. you only need the opencv library, if the image is small is very light to the CPU.
But if you want to see a "Bar" the easiest way is to use the line function:
C++: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
pt1 is a point in one corner of your image, pt2 is the point in where their x or Y axis is changing for example in the other code:
axis=(int)(image.size().width*(i/N));
If you really need a user friendly GUI, why don't you use Qt. It can be easily integrated with opencv and there are lot for tools to customize and create GUI. Take a look at the official link provided by Qt to integrate opencv. http://qt-project.org/wiki/OpenCV_with_Qt
精彩评论