Esempio n. 1
0
static void node_composit_exec_cvAnd(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
	CvArr* dst;
	CvArr* src1;
	CvArr* src2;
	CvArr* mask=NULL;
        CompBuf* dst_buf;

	if(out[0]->hasoutput==0) return;
	if((in[0]->data)){
                //Inputs
		src1 = BOCV_IplImage_attach(in[0]->data);
                mask = BOCV_Mask_attach(in[2]->data);
                
                //Output
                dst_buf=dupalloc_compbuf(in[0]->data);
                dst=BOCV_IplImage_attach(dst_buf);

                //Check Image - Mask sizes
                if(mask){
                    if (!BOCV_checkMask(src1, mask)){
                        node->error= 1;
                        return;
                    }
                }
                
                if(in[1]->data){
                    src2 = BOCV_IplImage_attach(in[1]->data);
                    //Checks
                    //Check Image Sizes
                    if(!BOCV_checkAreSameType(src1, src2)){
                        node->error= 1;
                        return;
                    }
                    //Check Image number Channels
                    if(!BOCV_checkSameNChannels(src1, src2)){
                        node->error= 1;
                        return;
                    }
                    cvAnd(src1, src2, dst, mask);
                    BOCV_IplImage_detach(src2);
                }else{
                    CvScalar s;
                    s.val[0]= (in[1]->vec[0]);
                    s.val[1]= (in[1]->vec[1]);
                    s.val[2]= (in[1]->vec[2]);
                    s.val[3]= 0;
                    cvAndS(src1, s, dst, mask);
                }
                
                out[0]->data= dst_buf;
		
                BOCV_IplImage_detach(src1);
                
                BOCV_IplImage_detach(mask);
                BOCV_IplImage_detach(dst);

	}
	
}
Esempio n. 2
0
static void node_composit_exec_cvSub(void *data, bNode *node, bNodeStack **in, bNodeStack **out) {
    CvArr* dst;
    CvArr* src1;
    CvArr* src2;
    CvArr* mask = NULL;
    CompBuf *dst_buf;

    if (out[0]->hasoutput == 0) return;
    if ((in[0]->data)) {
        src1 = BOCV_IplImage_attach(in[0]->data);

        if (in[2]->data) {
            mask = BOCV_Mask_attach(in[2]->data);
            if (!BOCV_checkMask(src1, mask)) {
                node->error = 1;
                return;
            }
        }

        //Create output
        dst_buf = dupalloc_compbuf(in[0]->data);
        dst = BOCV_IplImage_attach(dst_buf);


        //If there are second input
        if (in[1]->data) {
            src2 = BOCV_IplImage_attach(in[1]->data);
            if (!BOCV_checkAreSameType(src1, src2)) {
                node->error = 1;
                return;
            }
            if (!BOCV_checkSameNChannels(src1, src2)) {
                node->error = 1;
                return;
            }
            cvSub(src1, src2, dst, mask);
            BOCV_IplImage_detach(src2);
        } else {
            CvScalar s;
            s.val[0] = (in[1]->vec[0]);
            s.val[1] = (in[1]->vec[1]);
            s.val[2] = (in[1]->vec[2]);
            s.val[3] = 0;
            cvSubS(src1, s, dst, mask);
        }

        out[0]->data = dst_buf;
        BOCV_IplImage_detach(src1);
        BOCV_IplImage_detach(dst);
    }
}
Esempio n. 3
0
static void node_composit_exec_cvSmooth(void *data, bNode *node, bNodeStack **in, bNodeStack **out) {
    //TODO: Use atach buffers
    int w, h;
    int p1, p2;
    float p3, p4;
    int type;
    if (out[0]->hasoutput == 0) return;

    if (in[0]->data) {
        IplImage *img, *smth;
        CompBuf* dst_buf;
        img = BOCV_IplImage_attach(in[0]->data);
        w = img->width;
        h = img->height;
        //Make input data as odd value
        p1 = (int) in[1]->vec[0];
        if ((p1 % 2) == 0) {
            p1--;
        }
        //Make input data as odd value
        p2 = (int) in[2]->vec[0];
        if ((p2 % 2) == 0)
            p2--;
        
        p3 = in[3]->vec[0];
        p4 = in[4]->vec[0];

        dst_buf = alloc_compbuf(img->width, img->height, img->nChannels, 1);
        smth = BOCV_IplImage_attach(dst_buf);
        
        type= node->custom1;
        
        cvSmooth(img, smth, type, p1, p2, p3, p4);

        out[0]->data = dst_buf;
        
        BOCV_IplImage_detach(smth);
        BOCV_IplImage_detach(img);
    }

}
Esempio n. 4
0
static void node_composit_exec_cvDiv(void *data, bNode *node, bNodeStack **in, bNodeStack **out) {
    CvArr* dst;
    CvArr* src1;
    CvArr* src2;
    CompBuf *dst_buf;

    if (out[0]->hasoutput == 0) return;
    if ((in[0]->data) && in[1]->data) {
        //Get inuts
        src1 = BOCV_IplImage_attach(in[0]->data);
        src2 = BOCV_IplImage_attach(in[1]->data);

        //Create output
        dst_buf = dupalloc_compbuf(in[0]->data);
        dst = BOCV_IplImage_attach(dst_buf);


        //Check for inputs    
        if (!BOCV_checkAreSameType(src1, src2)) {
            node->error = 1;
            return;
        }
        if (!BOCV_checkSameNChannels(src1, src2)) {
            node->error = 1;
            return;
        }

        cvDiv(src1, src2, dst, in[2]->vec[0]);

        //Output
        out[0]->data = dst_buf;

        //Release memory
        BOCV_IplImage_detach(src1);
        BOCV_IplImage_detach(src2);
        BOCV_IplImage_detach(dst);
    }
}
Esempio n. 5
0
static void node_composit_exec_cvErode(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
	int iterations;	
	IplImage *src, *dst;
	CompBuf *dst_buf;

	if(in[0]->hasinput==0) return;
	if(out[0]->hasoutput==0) return;

	src= BOCV_IplImage_attach(in[0]->data);
	dst_buf = dupalloc_compbuf(in[0]->data);
	iterations=(int)in[1]->vec[0];
	dst = BOCV_IplImage_attach(dst_buf);

	cvErode(src,dst,0,iterations);

	out[0]->data = dst_buf;

	BOCV_IplImage_detach(src);
	BOCV_IplImage_detach(dst);


}