Results 1 to 2 of 2

Thread: How to display image transformed into integral image on label?(OpenCV)

  1. #1
    Join Date
    Oct 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question How to display image transformed into integral image on label?(OpenCV)

    Hi, I would like to put the output in the white area, this is my GUIhaar.JPG,and this output擷取.JPG
    This is my code:
    Qt Code:
    1. #include "haar.h"
    2. #include "ui_haar.h"
    3. #include "opencv2/objdetect/objdetect.hpp"
    4. #include "opencv2/highgui/highgui.hpp"
    5. #include "opencv2/imgproc/imgproc.hpp"
    6. #include <iostream>
    7. using namespace std;
    8. using namespace cv;
    9. HAAR::HAAR(QWidget *parent) :
    10. QMainWindow(parent),
    11. ui(new Ui::HAAR)
    12. {
    13. ui->setupUi(this);
    14. }
    15.  
    16. HAAR::~HAAR()
    17. {
    18. delete ui;
    19. }
    20.  
    21. void HAAR::on_pushButton_clicked()
    22. {
    23. Mat frame;
    24. //VideoCapture cap(0);
    25. //while(true){
    26. //cap>>frame;
    27.  
    28. frame=cv::imread("C:\\Users\\OpenCL\\Documents\\QT Pro\\H\\1.jpg");//read image.
    29. //double t = (double)getTickCount();
    30. float A[30][30];
    31. //float **A = (float**)malloc(sizeof(float)*(frame.cols+1)*(frame.rows+1));
    32. //for(int k=0;k<frame.cols+1;k++) A[k]=(float*)malloc(sizeof(float)*(frame.rows+1));
    33. for(int i=0;i<frame.cols+1;i++) for(int j=0;j<frame.rows+1;j++)A[i][j]=0;
    34. for(int y=0;y<frame.rows;y++){
    35. float sum=0;
    36. uchar* ptr1=frame.ptr<uchar>(y);
    37. for (int x=0; x<frame.cols; x++) {
    38. sum=sum+(float)((ptr1[3*x]+ptr1[3*x+1]+ptr1[3*x+2])/3);
    39.  
    40. A[x+1][y+1] = A[x+1][y] + sum;
    41.  
    42. }
    43. cout<<endl;
    44. }
    45.  
    46. cout<<"Integration Picture:"<<endl<<endl;
    47. for(int j=0;j<frame.rows+1;j++,cout<<endl)
    48. for(int i=0 ;i<frame.cols+1;i++)
    49. {
    50. cout<<A[i][j]<<" ";
    51.  
    52.  
    53. cout<<endl;
    54. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to display image transformed into integral image on label?(OpenCV)

    You want the A values to be displayed in the window instead of written to stdout?

    If so just build a QString with concatenation, using QString::number() to format the floats into strings.

    Or use a QTextStream on a QString pointer and stream similar to what you have now, then take the resulting QString.

    Cheers,
    _

Similar Threads

  1. efficient way to display opencv image into Qt
    By gerardpuducul in forum Qt Programming
    Replies: 5
    Last Post: 25th January 2016, 09:59
  2. HOW TO DISPLAY A RECTANGLE ON AN IMAGE on a label
    By qt_user in forum Qt Programming
    Replies: 4
    Last Post: 6th August 2010, 16:19
  3. Replies: 6
    Last Post: 30th July 2010, 08:23
  4. Replies: 1
    Last Post: 23rd May 2009, 10:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.