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:
#include "haar.h"
#include "ui_haar.h"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
ui(new Ui::HAAR)
{
ui->setupUi(this);
}
HAAR::~HAAR()
{
delete ui;
}
void HAAR::on_pushButton_clicked()
{
Mat frame;
//VideoCapture cap(0);
//while(true){
//cap>>frame;
frame=cv::imread("C:\\Users\\OpenCL\\Documents\\QT Pro\\H\\1.jpg");//read image.
//double t = (double)getTickCount();
float A[30][30];
//float **A = (float**)malloc(sizeof(float)*(frame.cols+1)*(frame.rows+1));
//for(int k=0;k<frame.cols+1;k++) A[k]=(float*)malloc(sizeof(float)*(frame.rows+1));
for(int i=0;i<frame.cols+1;i++) for(int j=0;j<frame.rows+1;j++)A[i][j]=0;
for(int y=0;y<frame.rows;y++){
float sum=0;
uchar* ptr1=frame.ptr<uchar>(y);
for (int x=0; x<frame.cols; x++) {
sum=sum+(float)((ptr1[3*x]+ptr1[3*x+1]+ptr1[3*x+2])/3);
A[x+1][y+1] = A[x+1][y] + sum;
}
cout<<endl;
}
cout<<"Integration Picture:"<<endl<<endl;
for(int j=0;j<frame.rows+1;j++,cout<<endl)
for(int i=0 ;i<frame.cols+1;i++)
{
cout<<A[i][j]<<" ";
cout<<endl;
}
#include "haar.h"
#include "ui_haar.h"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
HAAR::HAAR(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::HAAR)
{
ui->setupUi(this);
}
HAAR::~HAAR()
{
delete ui;
}
void HAAR::on_pushButton_clicked()
{
Mat frame;
//VideoCapture cap(0);
//while(true){
//cap>>frame;
frame=cv::imread("C:\\Users\\OpenCL\\Documents\\QT Pro\\H\\1.jpg");//read image.
//double t = (double)getTickCount();
float A[30][30];
//float **A = (float**)malloc(sizeof(float)*(frame.cols+1)*(frame.rows+1));
//for(int k=0;k<frame.cols+1;k++) A[k]=(float*)malloc(sizeof(float)*(frame.rows+1));
for(int i=0;i<frame.cols+1;i++) for(int j=0;j<frame.rows+1;j++)A[i][j]=0;
for(int y=0;y<frame.rows;y++){
float sum=0;
uchar* ptr1=frame.ptr<uchar>(y);
for (int x=0; x<frame.cols; x++) {
sum=sum+(float)((ptr1[3*x]+ptr1[3*x+1]+ptr1[3*x+2])/3);
A[x+1][y+1] = A[x+1][y] + sum;
}
cout<<endl;
}
cout<<"Integration Picture:"<<endl<<endl;
for(int j=0;j<frame.rows+1;j++,cout<<endl)
for(int i=0 ;i<frame.cols+1;i++)
{
cout<<A[i][j]<<" ";
cout<<endl;
}
To copy to clipboard, switch view to plain text mode
Bookmarks