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