Ask Your Question

baro's profile - activity

2020-11-16 15:30:13 -0600 received badge  Nice Question (source)
2019-06-04 10:55:27 -0600 received badge  Notable Question (source)
2018-06-13 16:33:21 -0600 received badge  Popular Question (source)
2016-09-06 03:05:29 -0600 commented question Detector particular persons

simply ask for advice on how to achieve the recognition regardless of the final task .

2016-09-05 20:59:07 -0600 asked a question Detector particular persons

Hello at all! I would creat a C program with IPCam where I can recognize 10 particular persons. IPCam is positioned as a surveillance camera. This because I have to generate an allarm when these people are in a vision. Could you kindly tell me a good starting point? Could you tell me some examples with fairly recent methods? Thanks you very much for help

2016-03-17 06:58:46 -0600 asked a question intersection compare

hallo at all! could you tell me with simple words what is the intersection in compareHist? I would know the theory of intersection(CV_COMP_INTERSECT) for compare two rgb histogram. thanks you at all

2016-02-13 03:01:54 -0600 asked a question depth image imread

Hello at all! I'm writing because I have read the function imread but I don't understand what means the flag CV_LOAD_IMAGE_ANYDEPTH; could anyone tell me what is the depth of image? And what means ' If the flag is set, return 16-bit/32-bit image when the input has the corresponding depth' ? thanks you soo much for help

2016-02-04 03:20:49 -0600 received badge  Supporter (source)
2016-02-03 09:30:09 -0600 commented answer compareHist

@StevenPuttemans ok, but I need a theoretical explanation to define what is the correlation , the chi square and the intersection . I use three methods already in my program so working.

2016-02-03 07:41:12 -0600 asked a question compareHist

Hello at all! someone could tell me the principal differeces between comparison methods as CV_COMP_CHISQR, CV_COMP_CORREL and CV_COMP_INTERSECT? Could tell me also the mean of this methods and the theory behind it? thanks you soo much

2016-02-01 09:33:28 -0600 commented question people detection and tracking and state of art

thanks you soo much @Eduardo

2016-02-01 07:39:17 -0600 received badge  Student (source)
2016-02-01 07:22:44 -0600 asked a question people detection and tracking and state of art

Hello at all! Could someone tell me the state of art regard to people detect and tracking? Or someone could tell me where can I find it? thanks you soo much for help

2016-01-28 04:49:11 -0600 commented question compareHist threshold

I have more problems to set correlation thresholds!! Thanks you soo much

2016-01-27 14:05:33 -0600 asked a question compareHist threshold

Hi at all!!! I'm doing a comparison between two different images but I have a problem to set the threshold for three color: blue, green and red. Could anyone tell me how I set these thresholdes? Below I post my program and I am attaching the two different images. The scope of my program is detect object or people doing a comparison with background image and show parts that are different in red.

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <opencv2\opencv.hpp>
#include "opencv\highgui.h"
#include "opencv\cv.h"
using namespace cv;
using namespace std;
void add_piece_of_frame(const Mat&, Mat&, int, int);
void add_piece_of_frame_red(const Mat&, Mat&, int, int);
int const dim = 20;
int main(int argc, char** argv)
{
    int const block = 80;
    //read image
    Mat background = imread("Scene1.jpg",CV_LOAD_IMAGE_COLOR);
    //check read image
    if(! background.data )                              
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }
    //shows reference image
    imshow("background di riferimento", background);
    waitKey(1);
    //vectors for background histograms
    Mat hB_b[block]; 
    Mat hB_g[block];
    Mat hB_r[block]; 
    //vectors for image histograms 
    Mat hC_b[block];  
    Mat hC_g[block];   
    Mat hC_r[block]; 
    //**************variables for histograms*********************************************************************************
    //number of histogram bins
    int histSize = 256;
    //range per (b,g,r)
    float range[] = { 0, 256 } ;
    const float* histRange = { range };
    bool uniform = true;
    bool accumulate = false;
//**********************************************************************************************************************************************
    int count = 0; //counter variable for background cycle
    int count_c = 0; //counter variable for current cycle
    int nFrame = 0; //counter variable for numerated frames
    for(int a=0; a<320; a+=dim)
    {
        for(int b=40; b<140; b+=dim)
        {
            //block 
            Mat SUPPORT (background, Rect(a,b,dim,dim));
            //split block to obtain color elements
            vector<Mat> bgr_planes;
            split( SUPPORT, bgr_planes ); 
            //calculate histograms for each color
            calcHist( &bgr_planes[0], 1, 0, Mat(), hB_b[count], 1, &histSize, &histRange, uniform, accumulate );//blu
            calcHist( &bgr_planes[1], 1, 0, Mat(), hB_g[count], 1, &histSize, &histRange, uniform, accumulate );//green
            calcHist( &bgr_planes[2], 1, 0, Mat(), hB_r[count], 1, &histSize, &histRange, uniform, accumulate );//red
            count++;
        }
    }
    //VideoCapture cap("tagliato.avi");
    Mat current_frame = imread("Scene1_2.jpg",CV_LOAD_IMAGE_COLOR);
    //while(1)
    //{
        //Mat current_frame;
        //bool img = cap.read(current_frame); 
        //if(!img) 
            //break;
        //---------Mats' vector for recostruction image  (save parts of original image) ---------------------
        Mat recostruct[block];
        //matrix for modified output
        //Mat output = cv::Mat::zeros(240, 320, CV_8UC3);
        Mat output_chi_sq = current_frame.clone();
        Mat output_correl = current_frame.clone();
        Mat output_intersect = current_frame.clone();
        //vettori per il salvataggio dei punti iniziali di ricostruzione
        int aa[block];
        int bb[block];
        for(int a=0; a<320; a+=dim)
        {
            for(int b=40; b<140; b+=dim)
            {
                Mat SUPPORT_2 (current_frame, Rect(a,b,dim,dim));
                //save block to recostruction
                recostruct[count_c] = SUPPORT_2.clone();
                //save block's points
                aa[count_c] = a;
                bb[count_c] = b;
                //split current block
                vector<Mat> bgr_planes_c;
                split( SUPPORT_2, bgr_planes_c );
                //calculate histograms for each color
                calcHist( &bgr_planes_c[0], 1, 0, Mat(), hC_b[count_c], 1, &histSize, &histRange, uniform, accumulate );//blu
                calcHist( &bgr_planes_c[1], 1, 0, Mat(), hC_g[count_c], 1, &histSize, &histRange, uniform, accumulate );//gren
                calcHist( &bgr_planes_c[2], 1, 0, Mat(), hC_r[count_c], 1, &histSize, &histRange, uniform, accumulate );//red ...
(more)
2016-01-18 05:38:23 -0600 commented question canny on RGB color

@berak I don't know I hope to find a function more robust that canny on grey. OpenCV provides something? thanks you so much

2016-01-15 10:22:53 -0600 asked a question canny on RGB color

hello! I've a simple question. Can I use Canny function directly on RGB image and not on RGB image converted in gray? If it is possible, could you show me one exapmple? thanks you so much for help

2016-01-14 06:54:10 -0600 commented answer How to record the time of stay by detected people in a video?

@sturkmen I have 2.4.10 version of openCV. How I change it if I not change my openCV version? thanks you !

2016-01-14 03:17:16 -0600 commented answer How to record the time of stay by detected people in a video?

Hi! excuse me but if I use code above it not runs because I get the error that tell me; 1_: error C3861: 'createBackgroundSubtractorMOG2': identifier not found 2_: error C2039: 'apply' : is not a member of 'cv::BackgroundSubtractor' Now how can I fix this? thanks you so much for help!

2016-01-13 10:48:55 -0600 asked a question detection and rect

hello! I'm trying a program that I find on web. This program do a people detect. I have a little problem and I think that this is very trivial.

Below I Post the code but I have problem on each declaration of vectors. I don't know how can I fix this problem!!! Thanks you for your help.

using namespace cv; using namespace std;

//La funzione che farà tutto il lavoro void detectROIObject(Mat frame);

//istanzio le variabili che mi servono cv::Mat frame; cv::Mat back; cv::Mat fore;

std::vector<std::vector &gt;="" contours;="" vector="" rectangle;<="" p="">

//definisco il video da processare (0 o -1 per la webcam) cv::VideoCapture cap("pathdelvideo");

//istanzio un background subtractor per eliminare lo sfondo cv::BackgroundSubtractorMOG bg(50000, 100.0, 0.5);

int main(int argc, char *argv[]) { //apro la finestra frame cv::namedWindow("Frame");

//comincio a processare il video frame per frame
while ( cap.read(frame) )
{
    //quando termina esci dal while e chiudi
    if( frame.empty() )
    {
        printf(" --(!) No captured frame -- Break!");
        break;
    }

    //salva il frame nella variabile omonima
    cap >> frame;

    //lancia la funzione passando il frame come parametro
    detectROIObject(frame);

    //mostra il video principale
    cv::imshow("Frame",frame);

    if(cv::waitKey(30) >= 0) break;
}

return 0;

}

void detectROIObject(Mat frame) {

//elimina il backgound
bg.operator ()(frame,fore, -1);
//processa l'immagine in primo piano per migliorare la precisione dei contorni
cv::threshold(fore,fore,30,255,CV_THRESH_BINARY);   
cv::dilate(fore,fore,cv::Mat());

vector<vector > contours;
vector hierarchy;

//trova i contorni
findContours( fore, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

//Approssima i contorni a polighoni + prendi i rettangoli migliori 
//per l'oggetto che stiamo considerando
vector<vector > contours_poly( contours.size() );
vector boundRect( contours.size() );

for( int i = 0; i < contours.size(); i++ )
{ 
    approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
    boundRect[i] = boundingRect( Mat(contours_poly[i]) );

}


//Disegna i rettangoli
for( int i = 0; i< contours.size(); i++ )   {       
          //aventi area più grande di 1000 px   
          if (boundRect[i].area() > 1000) {

        Point pt1;
        pt1.x = boundRect[i].tl().x;
        pt1.y = boundRect[i].tl().y;

        Point pt2;
        pt2.x = boundRect[i].br().x;
        pt2.y = boundRect[i].br().y;

        Rect rect(pt1, pt2);

        cv::rectangle( frame, rect, cvScalar(0, 255, 0, 0), 1, 8, 0);
    }
}
//Mostra anche cosa accade nello sfondo
cv::imshow("Foreground",fore);

}

2016-01-12 08:52:25 -0600 asked a question color detect

Hello at all! I'm trying to do a people detect using color histogram to realize it. I would know if exists a function of openCV that works as Canny but not with grayscale. More precisely a funtion that works with color directly. I think that, if exists it, is much more robust that Canny. Could you show me one example? I use histograms to calculate the differences between two images. thank you so much for your help!

2016-01-11 09:26:12 -0600 commented question eigenvalue & eigenvector

@LorenaGdL since it had already been asked , you know this problem ?

2016-01-11 07:47:50 -0600 commented question eigenvalue & eigenvector

@StevenPuttemans I read this on one article. For person detect !!!!!!!!! I want know how I realize S matrix.

https://www.google.it/url?sa=t&rct=j&...

paragraph 2.1

2016-01-11 07:08:33 -0600 commented question eigenvalue & eigenvector

@StevenPuttemans yes people detect. I must calculate S matrix and after its eigenvalues and eigenvectors. But I don't know how I create S matrix as in picture. thanks you

2016-01-11 03:22:49 -0600 asked a question eigenvalues

Hello at all!!! I have a simply question. I have a Mat after read image with opencv. Now, how can I calculate eigenvalues and its eigenvectors? Could you show me an example? Thanks you so much

2016-01-09 05:51:08 -0600 asked a question eigenvalue & eigenvector

Hello at all! I must get from an image eigenvalues and eigenvectors to realize person detect with colors. How can I obtain eigenvalues and eigenvectors? The results are as the trace of matrix S where to each color band I use partial derivatives rx, ry, gx, gy, bx, by for the (r)ed, (g)reen and (b)lue bands?

image description

thanks for your time!

2016-01-08 05:13:48 -0600 commented question histogram comparison

@LorenaGdL Good morning! Could you help me on this argument?

2016-01-08 04:39:19 -0600 commented question histogram comparison

@berak ok if I change int to float the comparison is correct? what do you intend for historams type?

2016-01-08 04:16:24 -0600 commented question histogram comparison

@berak as you suggested I have modified the code as required. This program executes correctly the formula ? thanks you

2016-01-08 03:35:48 -0600 asked a question histogram comparison

Hi at all! I must do an histogram comparison with a formula that computes the intersection of histograms. My histograms have 256 bins. How I realize this formula correctly? I 'm using this for object tracking with colors.

enter code here

image description

Post below one my possible solution but I think that this not execute exactly the formula

int const block = 768;
Mat background = imread("Scene.jpg",CV_LOAD_IMAGE_COLOR);\\Scene1.jpg",CV_LOAD_IMAGE_COLOR);
//bacground histograms
Mat hB_b[block]; 
Mat hB_g[block];
Mat hB_r[block]; 
//currents histogram
Mat hC_b[block];  
Mat hC_g[block];   
Mat hC_r[block]; 
float sum_bkg_b = 0;
float sum_bkg_g = 0;
float sum_bkg_r = 0;

float summ_bkg_b[block];
float summ_bkg_g[block];
float summ_bkg_r[block];
for(int a=0; a<320; a+=10)
{
    for(int b=0; b<240; b+=10)
    {
             Mat SUPPORT (background, Rect(a,b,10,10));
             vector<Mat> bgr_planes;
         split( SUPPORT, bgr_planes ); 
             calcHist( &bgr_planes[0], 1, 0, Mat(), hB_b[count], 1, &histSize, &histRange, uniform, accumulate );
         calcHist( &bgr_planes[1], 1, 0, Mat(), hB_g[count], 1, &histSize, &histRange, uniform, accumulate );
         calcHist( &bgr_planes[2], 1, 0, Mat(), hB_r[count], 1, &histSize, &histRange, uniform, accumulate );
             for(int b=0; b<256; b++)
         {
           sum_bkg_b = sum_bkg_b + hB_b[count].at<int>(b);
           sum_bkg_g = sum_bkg_g + hB_g[count].at<int>(b);
           sum_bkg_r = sum_bkg_b + hB_r[count].at<int>(b);
         }
         summ_bkg_b[count] = sum_bkg_b; 
         summ_bkg_g[count] = sum_bkg_g;
         summ_bkg_r[count] = sum_bkg_r;
             count++;
    }
}
Mat current = imread("Scene2.jpg",CV_LOAD_IMAGE_COLOR);
for(int a=0; a<320; a+=10)
{
    for(int b=0; b<240; b+=10)
    {
        Mat SUPPORT_2 (current, Rect(a,b,10,10));
            ricostruzione[count_c] = SUPPORT_2.clone();
                vector<Mat> bgr_planes_c;
        split( SUPPORT_2, bgr_planes_c );
                calcHist( &bgr_planes_c[0], 1, 0, Mat(), hC_b[count_c], 1, &histSize, &histRange, uniform, accumulate );
        calcHist( &bgr_planes_c[1], 1, 0, Mat(), hC_g[count_c], 1, &histSize, &histRange, uniform, accumulate );
        calcHist( &bgr_planes_c[2], 1, 0, Mat(), hC_r[count_c], 1, &histSize, &histRange, uniform, accumulate );
                double f_intersect_b[block]; 
        double f_intersect_g[block];
        double f_intersect_r[block];
                float min_Bb = 0;
        float min_Bg = 0;
        float min_Br = 0;
        float min_Cb = 0;
        float min_Cg = 0;
        float min_Cr = 0;
        float min_num_b = 0;
        float min_num_g = 0;
        float min_num_r = 0;
        float min_sum_b = 0;
        float min_sum_g = 0;
        float min_sum_r = 0;
        float pos_min_b = 0;
        float sum_min_b = 0;
        float pos_min_g = 0;
        float sum_min_g = 0;
        float pos_min_r = 0;
        float sum_min_r = 0;
                for (int t=0; t<block; t++)
        {
            for (int u=0; u<256; u++)
            {
                             //intersect formula (BLU)***************************************************
                if (hB_b[t].at<int>(u) <= hC_b[t].at<int>(u))
                     pos_min_b = hB_b[t].at<int>(u);
                else 
                    pos_min_b = hC_b[t].at<int>(u);
                sum_min_b += pos_min_b;
                //intersect formula (GREEN)*************************************************
                if (hB_g[t].at<int>(u) <= hC_g[t].at<int>(u))
                    pos_min_g = hB_g[t].at<int>(u);
                else 
                     pos_min_g = hC_g[t].at<int>(u);
                sum_min_g += pos_min_g;
                //intersect formula (RED)***************************************************
                if (hB_r[t].at<int>(u) <= hC_r[t].at<int>(u))
                     pos_min_r = hB_r[t].at<int>(u);
                else 
                    pos_min_r = hC_r[t].at<int>(u);
                sum_mini_r += pos_min_r;                              
            }

             f_intersect_b[t] = sum_min_b / summ_bkg_b[t];
             f_intersect_g[t] = sum_min_g / summ_bkg_g[t];
             f_intersect_r[t] = sum_min_r / summ_bkg_r[t];
               }

thanks at all for your time!

2016-01-04 11:34:31 -0600 answered a question read video & recostruction

@LorenaGdL

include <iostream>

include <stdio.h>

include <math.h>

include <opencv2\opencv.hpp>

include "opencv\highgui.h"

include "opencv\cv.h"

using namespace cv; using namespace std;

void add_piece_of_frame(const Mat&, Mat&, int, int); void add_piece_of_frame_red(const Mat&, Mat&, int, int);

int main(int argc, char** argv) { //lettura immagine Mat background = imread("C:\Users\Fabrizio\Desktop\frame\VIDEO_PER_TESI\Scene1.jpg",CV_LOAD_IMAGE_COLOR); //controllo di avvenuta lettura corretta if(! background.data )
{ cout << "Could not open or find the image" << std::endl ; return -1; } //mostra immagine riferimento imshow("background di riferimento", background); waitKey(1); //vettori per istogrami sfondo Mat hB_b[768]; Mat hB_g[768]; Mat hB_r[768]; //vettori per istogrami immagine Mat hC_b[768];
Mat hC_g[768];
Mat hC_r[768];

/**************variabili necessarie per l'istogrmma da generare*********************************************************************************/
//numero di bins
int histSize = 256;
//range per (b,g,r)
float range[] = { 0, 256 } ;
const float* histRange = { range };
bool uniform = true;
bool accumulate = false;
//**********************************************************************************************************************************************
Mat b_hist_b, g_hist_b, r_hist_b;
Mat b_hist_c, g_hist_c, r_hist_c;
Mat back_hist;
Mat current_hist;

double somma_bkg_b = 0;
double somma_bkg_g = 0;
double somma_bkg_r = 0;

double sommatoria_bkg_b[768];
double sommatoria_bkg_g[768];
double sommatoria_bkg_r[768];

int conteggio = 0;
int conteggio_c = 0;
int cont_hist = 0;

/***********************************************************************************************************************************************/
//*******************inizio raccolta dati di riferimento*****************************************************************************************

for(int a=0; a<320; a+=10)
{
    for(int b=0; b<240; b+=10)
    {

        Mat SUPPORT (background, Rect(a,b,10,10));

        vector<Mat> bgr_planes;
        split( SUPPORT, bgr_planes ); 

        calcHist( &bgr_planes[0], 1, 0, Mat(), hB_b[conteggio], 1, &histSize, &histRange, uniform, accumulate );
        calcHist( &bgr_planes[1], 1, 0, Mat(), hB_g[conteggio], 1, &histSize, &histRange, uniform, accumulate );
        calcHist( &bgr_planes[2], 1, 0, Mat(), hB_r[conteggio], 1, &histSize, &histRange, uniform, accumulate );


        //hB_b[conteggio] = b_hist_b.clone();
        //hB_g[conteggio] = g_hist_b.clone();
        //hB_r[conteggio] = r_hist_b.clone();

        for(int b=0; b<256; b++)
        {
            somma_bkg_b = somma_bkg_b + hB_b[conteggio].at<int>(b);
            somma_bkg_g = somma_bkg_g + hB_g[conteggio].at<int>(b);
            somma_bkg_r = somma_bkg_b + hB_r[conteggio].at<int>(b);
        }
        sommatoria_bkg_b[conteggio] = somma_bkg_b; 
        sommatoria_bkg_g[conteggio] = somma_bkg_g;
        sommatoria_bkg_r[conteggio] = somma_bkg_r;

        conteggio++;
    }
}

//----------------------fine della prima parte (salvataggio dati)--------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------

CvCapture* capture = cvCreateFileCapture("C:\\Users\\Fabrizio\\Desktop\\frame\\VIDEO_PER_TESI\\Scene1.avi");
IplImage* frame;

cout <<"***************************************************************************************** "<< std::endl ;
cout <<"************************inizio parte corrente******************************************** "<< std::endl ;
cout <<"***************************************************************************************** "<< std::endl ;

int A=0;

while(true)
{
    frame = cvQueryFrame(capture); 
    if(!frame) break;      //check for valid frame
    Mat current(frame);
    //---------vettore che serve per ricostruire l'immagine (salvataggio di parti di immagine originali)--------------------------------------
    Mat ricostruzione[768];
    //matrice che serve per generare output modificato
    Mat output = cv::Mat::zeros(240, 320, CV_8UC3);

    //vettori per il salvataggio dei punti iniziali di ricostruzione
    int aa[768];
    int bb[768];

    for(int a=0; a<320; a+=10)
    {
        for(int b=0; b<240; b+=10)
        {
            Mat SUPPORT_2 (current, Rect(a,b,10,10));

            ricostruzione[conteggio_c] = SUPPORT_2.clone();

            aa[conteggio_c] = a;
            bb[conteggio_c] = b;

            vector<Mat> bgr_planes_c;
            split( SUPPORT_2, bgr_planes_c );

            calcHist( &bgr_planes_c[0], 1, 0, Mat(), hC_b[conteggio_c], 1, &histSize, &histRange, uniform, accumulate );
            calcHist( &bgr_planes_c[1], 1, 0, Mat(), hC_g[conteggio_c], 1, &histSize, &histRange, uniform, accumulate );
            calcHist( &bgr_planes_c[2], 1, 0, Mat(), hC_r[conteggio_c], 1, &histSize, &histRange, uniform, accumulate );

            conteggio_c++; 
        }
    }

    float f_chi_squared_b[768]; 
    float f_chi_squared_g[768];
    float f_chi_squared_r[768];

    bool f_chi_sq[768];

    Mat ...
(more)
2016-01-03 08:06:11 -0600 commented question read video & recostruction

@LorenaGdL excuse me if there isn't the modification of output but I think that are not necessary to fix the problem. The modifications are comparing and show a rect grid with red background based on the comparison . @berak Why -10? My image is 320x240. I must read image until last pix. If I use two images and 10x10 grid the program run correctly but if I use one image and a video from which use frame by frame (comparison between reference image and the current frame of video) don't run. My output is black.

2015-12-30 05:27:13 -0600 asked a question read video & recostruction

Hi at all!!! I'm reading video from my memory and I execute some operation on it. When I read video I take a single frame (320x240) , I separe it with 10x10 grid and I save the single "box" (10x10) in a vector (Mat recostruction[768]). I create an other vector wich contains bool value. Each cell of vector contains bool value. Based on the value of the cells I recostruct the single box with different background color (true= red background image, false=normal backgrund image). When I show my output the output window is black and I don't show my rebuilt video. How I fix this problem? thank you for your time!

CvCapture* capture = cvCreateFileCapture("Scene1.avi");
IplImage* frame;
while(true)
{
    frame = cvQueryFrame(capture);
    if(!frame) break;
    Mat current(frame);
    Mat ricostruzione[768];
    Mat output = cv::Mat::zeros(240, 320, CV_8UC3);
    int aa[768];
    int bb[768];
    for(int a=0; a<320; a+=10)
    {
        for(int b=0; b<240; b+=10)
        {
            Mat SUPPORT_2 (current, Rect(a,b,10,10));
            ricostruzione[conteggio_c] = SUPPORT_2.clone();
            aa[conteggio_c] = a;
            bb[conteggio_c] = b;
            /*---------------------------------------------
            some operations
            ----------------------------------------------*/
            conteggio_c++;
        }
    }
    conteggio_c = 0;
    bool recost[768];
    for ( int t=0; t<768; t++)
    {
        /*--------------------------------------
        some operations and filling bool vector
        ---------------------------------------*/
    }
    imshow("original", current);
    waitKey(1);
    imshow("OUTPUT", output);
    waitKey(1);
}
2015-12-18 09:03:09 -0600 commented answer RECOSTRUCTION IMAGE WITH OPENCV

@LorenaGdL Hi LorenaGdL excuse me for my question but how I insert it in a video sequence? In others words I must read a video sequence and execute some operations and display output with some parts in red background depending on operations performed. Thanks for your time

2015-12-15 13:47:02 -0600 commented answer RECOSTRUCTION IMAGE WITH OPENCV

@LorenaGdL Your help was very precious to me! thanks you soo much

2015-12-15 06:53:46 -0600 commented answer RECOSTRUCTION IMAGE WITH OPENCV

@LorenaGdL I'm using your first code that you suggest me and I obtain this error : error LNK2001: unresolved external symbol "void __cdecl add_piece_of_frame(class cv::Mat,class cv::Mat,int,int)" (?add_piece_of_frame@@YAXVMat@cv@@V12@HH@Z) error LNK2001: unresolved external symbol "void __cdecl add_piece_of_frame_red(class cv::Mat,class cv::Mat,int,int)" (?add_piece_of_frame_red@@YAXVMat@cv@@V12@HH@Z) fatal error LNK1120: 2 unresolved externals when I write:

void add_piece_of_frame(const Mat, Mat, int, int); void add_piece_of_frame_red(const Mat, Mat, int, int); int main(int argc, char** argv) { //istructions of main } void add_piece_of_frame(const Mat &A , Mat &B, int r, int c) { //corp of function } void add_piece_of_frame(const Mat &A , Mat &B, int r, int c) { //corp of function }

2015-12-15 02:34:42 -0600 commented answer RECOSTRUCTION IMAGE WITH OPENCV

@LorenaGdL excuse me for the question that I think is stupid but could you tell me the correct form to write the identifiers of the two functions? thanks you soo much for your help and excuse me also for the banal questions. I'm following your code to fix my problem

2015-12-15 02:27:16 -0600 received badge  Enthusiast
2015-12-14 12:02:31 -0600 commented question RECOSTRUCTION IMAGE WITH OPENCV

@LorenaGdL How can I read the image in CV_32FC3??? Ok I follow your advice but I don't understand very well the part of the channel that you have explained me (About not having 3-channel images when inputting them into vector ricostruzione, I'd suggest using instead of Mat ricostruzione[48]; the following: vector<mat> ricostruzione; ricostruzione.reserve(48);). Can you explain me with a exemple? thanks you soo much

2015-12-14 11:53:13 -0600 commented question RECOSTRUCTION IMAGE WITH OPENCV
2015-12-14 11:41:56 -0600 commented question RECOSTRUCTION IMAGE WITH OPENCV

excuse me but B is a zeros matrix....and I modify a piece of matrix only one time. In for cycle the Roi area change oech times. Or not?

2015-12-14 11:36:17 -0600 commented question RECOSTRUCTION IMAGE WITH OPENCV

I think that one problem is the read of matrix over the matrix size ( rows or columns)...but I think also that if the division is correct then the reconstruction must work....help meeeee

2015-12-14 11:30:45 -0600 commented question RECOSTRUCTION IMAGE WITH OPENCV

excuse me but with opencv I'm just the starting and I don't understand the problem. I divide one big matrix and I save orderly each single piece of matrix wich size is 40x40. After I take these pieces and I put them in a big matrix for output. I don't understand the problem of memory locations...

2015-12-14 07:23:25 -0600 commented question RECOSTRUCTION IMAGE WITH OPENCV

I think that my problem is the recostruction. when I use the function "add_piece_of_frame" it shows a all white image nd when I use other function it don't work and don't show anything. I suppose that image have 3 channel and when I divide it in "ricostruzione[m]" I don't have 3 channels.

when the program execute : " B(Roi) = B(Roi)+A.clone();" obtain this message:

Unhandled exception at 0x7427d8a8 in OPENCV_PROVA.exe: Microsoft C++ exception: cv::Exception at memory location 0x0017c6b8.. and in a prompt I have: opencv error: bad argument( when the input arrays in add/substract/multiply/divide functions have different types, the output array type must be explicitly specified) in cv::arithm_op, file ........\opencv\modules\core\src\arithm.cpp, line 1313 how to fix this? and the red?

2015-12-14 03:03:04 -0600 received badge  Editor (source)
2015-12-14 02:53:22 -0600 asked a question RECOSTRUCTION IMAGE WITH OPENCV

Hello to all!!! I'm doing a little project for rebuild une image. I must load image from my path then. I used a grid 40x40 pixels for divide image in some little images. I must then rebuild image in order adding a red background. I think that this project is a bit useless but this is for another project. For my project is very important the division of the image and its orderly reconstruction. I post below my solution:

#include <iostream>
#include <stdio.h>
#include <math.h>

#include <opencv2\opencv.hpp>
#include "opencv\highgui.h"
#include "opencv\cv.h"

using namespace cv;
using namespace std;

Mat add_piece_of_frame(Mat, Mat, int, int);
Mat add_piece_of_frame_red(Mat, Mat, int, int);

int main(int argc, char** argv)
{
    Mat bkg_read = imread("C:\\Users\\Fabrizio\\Desktop\\frame\\VIDEO_PER_TESI\\Scene1.jpg",CV_LOAD_IMAGE_COLOR);
    IplImage * bkg = cvCloneImage( &(IplImage)bkg_read );
    namedWindow("original", 1);
    cvShowImage("original", bkg);
    cvWaitKey(3333);

    //Mat background(bkg_read);


    Mat ricostruzione[48];
    int aa[48];
    int bb[48];
    int m = 0;

    for(int a=0; a<320; a+=40)
    {
        for(int b=0; b<240; b+=40)
        {
            Mat SUPPORT (bkg_read, Rect(a,b,40,40));
            ricostruzione[m] = SUPPORT.clone();
            aa[m] = a;
            bb[m] = b;
            cout<<"coordinate:  "<<endl;
            cout<<"a:  "<<aa[m];
            cout<<"   b:  "<<bb[m]<<endl;

            m++;
        }
    }

    int A=0;

    while(A<1)
    {
        Mat output = cv::Mat::zeros(240, 320, CV_32FC3);
        Mat output_red = cv::Mat::zeros(240, 320, CV_32FC3);


        for ( int t=0; t<48; t++)
        {
            output_red = add_piece_of_frame_red(ricostruzione[t] , output_red, aa[t] , bb[t]);
        }

        IplImage * exit_red = cvCloneImage( &(IplImage)output_red );
        namedWindow("output_red", 1);
        cvShowImage("output_red",exit_red);
        cvWaitKey(3333);



        for ( int u=0; u<48; u++)
        {
            output = add_piece_of_frame(ricostruzione[u] , output, aa[u] , bb[u]);
        }

        IplImage * exit = cvCloneImage( &(IplImage)output );
        namedWindow("output", 1);
        cvShowImage("output",exit);
        cvWaitKey(3333);

    }

}

Mat add_piece_of_frame(Mat A , Mat B, int r, int c)
{
    Rect Roi(r, c, 40, 40);
    B(Roi) = B(Roi) + A.clone();
    return B;
}

Mat add_piece_of_frame_red(Mat A, Mat B, int r, int c)
{
    Scalar color = Scalar(0, 0, 255);   
    Mat mask = Mat(40, 40, CV_32FC3, color);
    Mat result;
    addWeighted(A, 0.5, mask, 0.5, 0, result, CV_32FC3); 

    Rect Roi(r, c, 40, 40);             

    B(Roi) = B(Roi) + result.clone();

    return B;
}