Here is a piece of code I written.
image = Mat2QImage(frame2Copy);
ui->label->setPixmap(QPixmap::fromImage(image).scaled(ui->label->width(),ui->label->height(),Qt::KeepAspectRatio));
imshow("frame2Copy", frame2Copy);
You can see that I want to translate a frame(cv::Mat) into an QImage, and then display it in a QLabel. The problem is that I can not comment the last line code:
imshow("frame2Copy", frame2Copy);
If this line of code is commented, the program will crashed. I do not need the frame to show in another new opened window since I have displayed it in a QLabel. However, I cannot remove this code. I can't figure out why. Can someone help me? Thanks very much.
Related
I just started using Direct2D yesterday. I want to use the DrawLine function.
But when i call the function that draws the line, the line will appear but a black background also appears
How can i get rid of the black background?
I tried to clear to NULL but that didnĀ“t help.
I dont know what the problem is because i have nowhere declared a background.
I am looking for a way to display the output from a C++ program in a separate window. I am just hoping someone could point me in the right direction. Just running a simple count statement and displaying that on a separate pop up screen would be awesome and I could run with it from there.
To hopefully help clarify a little.. Something similar to this would work http://wwww.youtube.com/watch?v=IXtm7cI21vM
I have a simple problem however I'm not sure how it could be solved. I have the following code (c++):
Mat myImage;
for(;;){
imshow("Name", myImage);
}
Lets make the assumption that myImage is already populated with an image here. For some reason this very simple code is causing a memory leak. I read somewhere online that supplying imshow with the same image results in imshow adding it as a seperate axis, increase the memory comsumption.
Basically I dont know how to stop this memory leak. Any ideas?
Thanks.
Edit 1
Here is a screen shot of what I'm seeing when analysing memory usage.
Edit 2
Here is an example xcode project, made from scratch to display this issue. If you cannot run xcode, I've also provided a copy of the code on pastebin here. The project files can be downloaded from here.
I may be misunderstanding how to do this, hopefully somebody can clarify.
I have placed a QLabel on my main window from inside Qt Designer. Currently, it just displays the letters "TextLabel" when I run the program.
I have a line edit where I type in the path to an image, which then loads the image as a QImage into memory (I have this working).
Finally, I want to display this QImage. I was told this can be done by QLabels. I have done the following, but nothing is happening:
ui.input_label->setPixmap(QPixmap::fromImage(my_qimage));
Why is nothing happening? How can I display this image?
If you are sure the image file is ok but then the problem is probably with loading the file into the QImage. If you are calling QImage::load(), you are probably getting a return value of false.
All,
I must have a fundamental neuron missing, but I cannot get a simple program to load a PNG file and display it in a window. I'm not sure if it is a QPixmap, a QPicture, or what. All of the samples in the QTCreator are a bit more than I need right now. Baby steps...
I can get the window to display, and the program doesn't barf when I try to load the PNG, but it never gets displayed.
If someone would post a simple program to load a PNG from a file and display it, it would greatly appreciated. (I know, asking a lot, but...).
Thanks!
:bp:
this example is minimal: http://doc.trolltech.com/4.6/widgets-imageviewer.html
You will want to have a look at the function ImageViewer::open():
Build a QImage object from a filename;
Convert your QImage to a QPixmap with QPixmap::fromImage();
Put your QPixmap in a QLabel with QLabel::setPixmap().
The QImage object will automatically chose an appropriate reader according to the format of the image it detects in step 1.