• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cvScalarAll函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cvScalarAll函数的典型用法代码示例。如果您正苦于以下问题:C++ cvScalarAll函数的具体用法?C++ cvScalarAll怎么用?C++ cvScalarAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cvScalarAll函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

void main() {
	IplImage* img;
	CvCapture* cap=cvCaptureFromCAM(0);
	cvNamedWindow("Line Counter", 1);
	CvFont* font1=new CvFont;
	CvFont* font2=new CvFont;
	cvInitFont(font1, CV_FONT_HERSHEY_SIMPLEX, 0.5f, 1.0f, 0, 3, 8);
	cvInitFont(font2, CV_FONT_HERSHEY_SIMPLEX, 0.5f, 1.0f, 0, 2, 8);
	int val=0, axx=0, bxx=0;
	char text[8];
	for (;;) {
		img = cvQueryFrame(cap);
		if (!img) break;
		IplImage* gray1=cvCreateImage(cvSize(img->width, img->height), 8, 1);
		IplImage* edge1=cvCreateImage(cvSize(img->width, 16), 8, 1);
		cvCvtColor(img, gray1, 7);
		extract(gray1, edge1);
		dy(edge1, edge1);
		cvThreshold(edge1, edge1, 10, 255, CV_THRESH_BINARY_INV);
		val=count(edge1);
		if (val==0&&axx==0) { axx=1; }
		if (val==2&&axx==1) { axx=0; bxx++; }
		sprintf(text, "%i", bxx);
		comb(gray1, edge1);
		cvPutText(gray1, text, cvPoint(10, 160), font1, cvScalarAll(255));
		cvPutText(gray1, text, cvPoint(10, 160), font2, cvScalarAll(0));
		cvShowImage("Line Counter", gray1);
		if (cvWaitKey(5) > 0) break;
		cvReleaseImage(&gray1);
		cvReleaseImage(&edge1);
	}
}
开发者ID:ArdWar,项目名称:Kuliah,代码行数:32,代码来源:LineCounter.cpp


示例2: data_histogram

IplImage *ocv_histogram1(IplImage *image) {
	if (!image) { present(1, "!image"); return NULL; }

	unsigned char *src = (unsigned char *)image->imageData;
	unsigned int width = image->width;
	unsigned int height = image->height;
	unsigned int widthStep = image->widthStep;

	double frequencies[256];
	data_histogram(frequencies, src, width, height, widthStep);

	IplImage *image2 = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
	cvSet(image2, cvScalarAll(0), NULL);

	double spacing = (double)width / 256;
	for (int i = 0; i < 255; i++) {
		cvLine(image2,
			cvPoint((int)(i *	spacing), height * (1 - frequencies[i])),
			cvPoint((int)((i+1)*spacing), height * (1 - frequencies[i])),
			cvScalarAll(255),
			1,8,0);
	}

	return image2;
}
开发者ID:changeyourdestiny,项目名称:DIP,代码行数:25,代码来源:ocv_histogram.c


示例3: projectImg

static void projectImg(IplImage *src, int64_t TRANS_X, int64_t TRANS_Y,
		IplImage *dst, CvMat *tmatrix) {
	if (tmatrix->rows == 2) {
		//translate
		CvMat* result = cvCreateMat(2, 3, CV_32FC1);
		cvSetReal2D(result, 0, 0, cvGetReal2D(tmatrix, 0, 0));
		cvSetReal2D(result, 0, 1, cvGetReal2D(tmatrix, 0, 1));
		cvSetReal2D(result, 1, 0, cvGetReal2D(tmatrix, 1, 0));
		cvSetReal2D(result, 1, 1, cvGetReal2D(tmatrix, 1, 1));
		cvSetReal2D(result, 0, 2, cvGetReal2D(tmatrix, 0, 2) + TRANS_X);
		cvSetReal2D(result, 1, 2, cvGetReal2D(tmatrix, 1, 2) + TRANS_Y);
		cvWarpAffine(src, dst, result, CV_INTER_LINEAR, cvScalarAll(0));
		cvReleaseMat(&result);
	} else if (tmatrix->rows == 3) {
		//translate matrix
		CvMat* offset = cvCreateMat(3, 3, CV_32FC1);
		cvSetReal2D(offset, 0, 0, 1);
		cvSetReal2D(offset, 0, 1, 0);
		cvSetReal2D(offset, 0, 2, TRANS_X);
		cvSetReal2D(offset, 1, 0, 0);
		cvSetReal2D(offset, 1, 1, 1);
		cvSetReal2D(offset, 1, 2, TRANS_Y);
		cvSetReal2D(offset, 2, 0, 0);
		cvSetReal2D(offset, 2, 1, 0);
		cvSetReal2D(offset, 2, 2, 1);
		//translate
		CvMat* result = cvCreateMat(3, 3, CV_32FC1);
		cvMatMul(offset, tmatrix, result);
		cvWarpPerspective(src, dst, result, CV_INTER_LINEAR, cvScalarAll(0));
		cvReleaseMat(&offset);
		cvReleaseMat(&result);
	}
}
开发者ID:juanbarrios,项目名称:multimedia_tools,代码行数:33,代码来源:image_stitching.c


示例4: cvCreateImage

int CV_CalcHistTest::prepare_test_case( int test_case_idx )
{
    int code = CV_BaseHistTest::prepare_test_case( test_case_idx );

    if( code > 0 )
    {
        CvRNG* rng = ts->get_rng();
        int i;

        for( i = 0; i <= CV_MAX_DIM; i++ )
        {
            if( i < cdims )
            {
                int nch = 1; //cvTsRandInt(rng) % 3 + 1;
                images[i] = cvCreateImage( img_size,
                    img_type == CV_8U ? IPL_DEPTH_8U : IPL_DEPTH_32F, nch );
                channels[i] = cvTsRandInt(rng) % nch;

                cvRandArr( rng, images[i], CV_RAND_UNI,
                    cvScalarAll(low), cvScalarAll(high) );
            }
            else if( i == CV_MAX_DIM && cvTsRandInt(rng) % 2 )
            {
                // create mask
                images[i] = cvCreateImage( img_size, IPL_DEPTH_8U, 1 );
                // make ~25% pixels in the mask non-zero
                cvRandArr( rng, images[i], CV_RAND_UNI,
                    cvScalarAll(-2), cvScalarAll(2) );
            }
        }
    }

    return code;
}
开发者ID:SCS-B3C,项目名称:OpenCV2-2,代码行数:34,代码来源:ahistograms.cpp


示例5: on_mouse

void on_mouse(int event, int x, int y, int flags, void*){  if(!img)
    return;

  if(event == CV_EVENT_LBUTTONUP){
    pt = cvPoint(x, y);

    if(prev_pt.x < 0)
      prev_pt = pt;
    
    cvRectangle(img, prev_pt, pt, cvScalarAll(255), 2, 8, 0);
    cvShowImage("学生証スキャナー", img);
  }

  else if(event == CV_EVENT_LBUTTONDOWN){
    cvCopy(img0, tmp);
    cvCopy(img0, img);
    cvShowImage("学生証スキャナー", tmp);
    prev_pt = cvPoint(x, y); //set the start point
  }  

  else if(event == CV_EVENT_MOUSEMOVE && (flags == CV_EVENT_FLAG_LBUTTON)){
    pt = cvPoint(x, y);
    
    if(prev_pt.x < 0)
      prev_pt = pt;
    
    cvCopy(img, tmp);
    cvRectangle(tmp, prev_pt, pt, cvScalarAll(255), 2, CV_AA, 0);
    cvShowImage("学生証スキャナー", tmp);
  }
}
开发者ID:hokuto-k,项目名称:CardScanner,代码行数:31,代码来源:CardScanner0.9.cpp


示例6: cvRandArr

void CV_BaseHistTest::init_hist( int /*test_case_idx*/, int hist_i )
{
    if( gen_random_hist )
    {
        CvRNG* rng = ts->get_rng();
        CvArr* h = hist[hist_i]->bins;
        
        if( hist_type == CV_HIST_ARRAY )
        {
            cvRandArr( rng, h, CV_RAND_UNI,
                cvScalarAll(0), cvScalarAll(gen_hist_max_val) );
        }
        else
        {
            int i, j, total_size = 1, nz_count;
            int idx[CV_MAX_DIM];
            for( i = 0; i < cdims; i++ )
                total_size *= dims[i];

            nz_count = cvTsRandInt(rng) % MAX( total_size/4, 100 );
            nz_count = MIN( nz_count, total_size );

            // a zero number of non-zero elements should be allowed
            for( i = 0; i < nz_count; i++ )
            {
                for( j = 0; j < cdims; j++ )
                    idx[j] = cvTsRandInt(rng) % dims[j];
                cvSetRealND( h, idx, cvTsRandReal(rng)*gen_hist_max_val );
            }
        }
    }
}
开发者ID:SCS-B3C,项目名称:OpenCV2-2,代码行数:32,代码来源:ahistograms.cpp


示例7: thinImage

void thinImage(IplImage *source, IplImage *destination) {
    for (int i = 0; i < 6; i++) {
        //cleanup
        
        for (int i = 1; i < source->height - 2; i++) {
            for (int j = 1; j < source->width - 2; j++) {
                if (cvGet2D(destination, i, j).val[0] == BLACK_PIXEL) {
                    if (firstCondition(destination, i, j) &&
                        secondCondition(destination, i, j) &&
                        thirdCondition(destination, i, j) &&
                        fourthCondition(destination, i, j) &&
                        fifthCondition(destination, i, j) &&
                        sixthCondition(destination, i, j)
                        ) 
                    {
                        cvSet2D(destination, i, j, cvScalarAll(DELETED_PIXEL));
                    }
                }
            }
        }
        
        for (int i = 0; i < source->height - 5; i++) {
            for (int j = 0; j < source->width - 5; j++) {
                if (cvGet2D(destination, i, j).val[0] == DELETED_PIXEL) {
                    cvSet2D(destination, i, j, cvScalarAll(WHITE_PIXEL));
                }
            }
        }

    }
}
开发者ID:LordZepto,项目名称:iOS-Sudoku-Solver,代码行数:31,代码来源:Common.c


示例8: flood

void flood(IplImage *img)
{
CvPoint seed=cvPoint(g,h);
CvScalar color=CV_RGB(250,0,0);
cvFloodFill(img,seed,color,cvScalarAll(200.0),cvScalarAll(200.0),NULL,CV_FLOODFILL_FIXED_RANGE,NULL);
printf("ab %d  %d\n",g,h);

}
开发者ID:adarshtadimari,项目名称:aadhar,代码行数:8,代码来源:floodfillvideo_3.c


示例9: get_minmax_bounds

void CV_MHIGlobalOrientTest::get_minmax_bounds( int i, int j, int type, CvScalar* low, CvScalar* high )
{
    CV_MHIBaseTest::get_minmax_bounds( i, j, type, low, high );
    if( i == INPUT && j == 2 )
    {
        *low = cvScalarAll(min_angle);
        *high = cvScalarAll(max_angle);
    }
}
开发者ID:ChristophGuillermet,项目名称:WHITECAT_opensource,代码行数:9,代码来源:amotiontemplates.cpp


示例10: main

int main (int argc, char **argv)
{
    int width=960, height=640;
    IplImage *img=0;
    double c, f;
    f = cvGetTickFrequency()*1000;
    
    int cx = width/2;
    int cy = height/2;
    double radius = 100;
    double angle = 0;
    CvScalar color = cvScalarAll(255);
    
    CvFont font;
    cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 1.0, 1.0, 1, CV_AA);
    
    cvNamedWindow ("hexagon", CV_WINDOW_AUTOSIZE);
    while (1) {
        
        // (1)allocate and initialize an image
        img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
        if(img == 0) return -1;
        cvZero(img);
        
        // (2) draw hexagon
        c = cvGetTickCount();
        myHexagon(img, cx, cy, radius, angle, color);
        printf("%fms\n", (cvGetTickCount()-c)/f);
        
        // (3)show the iamge, and press some key
        cvPutText(img, "Coordinate Right(D) Left(A) Up(W) Down(X)", cvPoint(10, 20), &font, cvScalarAll(255));
        cvPutText(img, "Rotate Right(R) Left(E)", cvPoint(10, 40), &font, cvScalarAll(255));
        cvPutText(img, "Radius Big(V) Small(C)", cvPoint(10, 60), &font, cvScalarAll(255));
        cvPutText(img, "Quit(Q, esc)", cvPoint(10, 80), &font, cvScalarAll(255));
        char s[64];
        sprintf(s, "cx:%d cy:%d radius:%f angle:%f", cx, cy, radius, angle);
        cvPutText(img, s, cvPoint(10, 110), &font, cvScalarAll(255));
        
        cvShowImage ("hexagon", img);
        char key = cvWaitKey (0);
        if (key == 27 || key == 'q') break;
        else if (key == 'r') angle += 5;
        else if (key == 'e') angle -= 5;
        else if (key == 'a') cx -= 5;
        else if (key == 'd') cx += 5;
        else if (key == 'w') cy -= 5;
        else if (key == 'x') cy += 5;
        else if (key == 'v') radius += 5;
        else if (key == 'c') radius -= 5;
    }
    
    cvDestroyWindow("hexagon");
    cvReleaseImage(&img);
    
    return 0;
}
开发者ID:shugoyamaguchi,项目名称:computer_vision,代码行数:56,代码来源:hexagon.c


示例11: reset

void ofxCvWatershed::segment() {
    reset();
    int nContours = cvFindContours( iplMarkersTempImg, storage, &contours, sizeof(CvContour),
                                   CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE );
    
    int i, j, compCount = 0;
    
    cvZero( iplMarkers32sImg );
    for( ; contours != 0; contours = contours->h_next, compCount++ ) {
        cvDrawContours( 
                       iplMarkers32sImg, 
                       contours, 
                       cvScalarAll(compCount+1),
                       cvScalarAll(compCount+1), 
                       -1, -1, 8, 
                       cvPoint(0,0) 
                       );
    }
    
    CvRNG rng = cvRNG(-1);
    colors = cvCreateMat( 1, compCount, CV_8UC3 );
    for( i = 0; i < compCount; i++ ) {
        uchar* ptr = colors->data.ptr + i*3;
        // no colors for now.
        ptr[0] = (uchar)0;//(cvRandInt(&rng)%180 + 50);
        ptr[1] = (uchar)0;//(cvRandInt(&rng)%180 + 50);
        ptr[2] = (uchar)0;//(cvRandInt(&rng)%180 + 50);
    }
    
    cvWatershed( iplTargetImg, iplMarkers32sImg );
    
    // paint the watershed image
    for( i = 0; i < iplMarkers32sImg->height; i++ ) {
        for( j = 0; j < iplMarkers32sImg->width; j++ ) {
            int idx     =  CV_IMAGE_ELEM( iplMarkers32sImg, int, i, j );
            uchar* dst  = &CV_IMAGE_ELEM( iplTargetImg, uchar, i, j*3 );
            if( idx == -1 ) {
                dst[0] = dst[1] = dst[2] = (uchar)255;
            } else if( idx <= 0 || idx > compCount ){
                dst[0] = dst[1] = dst[2] = (uchar)0; // should not get here
            }else {
                uchar* ptr = colors->data.ptr + (idx-1)*3;
                dst[0] = ptr[0]; dst[1] = ptr[1]; dst[2] = ptr[2];
            }
        }
    }
    //cvAddWeighted( watershed, 0.5, colorImg.getCvImage(), 0.5, 0, watershed );
    watershedImg     = iplTargetImg;
    watershedGrayImg = watershedImg;
    watershedGrayImg.threshold(140);
    //watershedGrayImg.invert();
    
    printf("contorus %i", contourFinder.findContours( watershedGrayImg, 10, 
                               (watershedImg.width * watershedImg.height)/ 2.f,
                               20, true));
}
开发者ID:atduskgreg,项目名称:ofxCvWatershed,代码行数:56,代码来源:ofxCvWatershed.cpp


示例12: setup

void setup(CvSize size) {
	BLACK1D = cvCreateImage(size, IPL_DEPTH_8U, 1);
	cvSet(BLACK1D, cvScalarAll(0), NULL);

	GRAY1D = cvCreateImage(size, IPL_DEPTH_8U, 1);
	cvSet(GRAY1D, cvScalarAll(127), NULL);
	
	WHITE1D = cvCreateImage(size, IPL_DEPTH_8U, 1);
	cvSet(WHITE1D, cvScalarAll(255), NULL);
}
开发者ID:changeyourdestiny,项目名称:DIP,代码行数:10,代码来源:operateImage.cpp


示例13: catcierge_haar_matcher_find_prey

int catcierge_haar_matcher_find_prey(catcierge_haar_matcher_t *ctx,
									IplImage *img, IplImage *thr_img,
									match_result_t *result, int save_steps)
{
	catcierge_haar_matcher_args_t *args = ctx->args;
	IplImage *thr_img2 = NULL;
	CvSeq *contours = NULL;
	size_t contour_count = 0;
	assert(ctx);
	assert(img);
	assert(ctx->args);

	// thr_img is modified by FindContours so we clone it first.
	thr_img2 = cvCloneImage(thr_img);

	cvFindContours(thr_img, ctx->storage, &contours,
		sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_NONE, cvPoint(0, 0));

	// If we get more than 1 contour we count it as a prey. At least something
	// is intersecting the white are to split up the image.
	contour_count = catcierge_haar_matcher_count_contours(ctx, contours);

	// If we don't find any prey 
	if ((args->prey_steps >= 2) && (contour_count == 1))
	{
		IplImage *erod_img = NULL;
		IplImage *open_img = NULL;
		CvSeq *contours2 = NULL;

		erod_img = cvCreateImage(cvGetSize(thr_img2), 8, 1);
		cvErode(thr_img2, erod_img, ctx->kernel3x3, 3);
		if (ctx->super.debug) cvShowImage("haar eroded img", erod_img);

		open_img = cvCreateImage(cvGetSize(thr_img2), 8, 1);
		cvMorphologyEx(erod_img, open_img, NULL, ctx->kernel5x1, CV_MOP_OPEN, 1);
		if (ctx->super.debug) cvShowImage("haar opened img", erod_img);

		cvFindContours(erod_img, ctx->storage, &contours2,
			sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_NONE, cvPoint(0, 0));
		cvReleaseImage(&erod_img);
		cvReleaseImage(&open_img);

		contour_count = catcierge_haar_matcher_count_contours(ctx, contours2);
	}

	if (ctx->super.debug)
	{
		cvDrawContours(img, contours, cvScalarAll(0), cvScalarAll(0), 1, 1, 8, cvPoint(0, 0));
		cvShowImage("Haar Contours", img);
	}

	cvReleaseImage(&thr_img2);

	return (contour_count > 1);
}
开发者ID:JoakimSoderberg,项目名称:catcierge,代码行数:55,代码来源:catcierge_haar_matcher.c


示例14: graficarHistograma

void graficarHistograma(IplImage *dst, size_t binsCount, size_t *bins) {
	static CvScalar hist_color = cvScalarAll(255);
	size_t hist_size = 256;
	//cvSet(ImagenHistorial, cvScalarAll(0), 0);

	//Actúo en función de la cantidad de colores de la imágen
	if (dst->nChannels == 1) {
		size_t max_value = 0;
		for (size_t i = 0; i < binsCount * hist_size; i++) {
			max_value = (bins[i] > max_value) ? bins[i] : max_value;
		}
		for (size_t i = 0; i < binsCount * hist_size; i++) {
			bins[i] /= max_value;
		}
		float w_scale = ((float)dst->width) / hist_size;

		//Graficar en la imagen
		for (int i = 0; i < hist_size; i++) {
			cvLine(dst,
				cvPoint(binsCount * hist_size + (int)(i       * w_scale), dst->height - bins[i]),
				cvPoint(binsCount * hist_size + (int)((i + 1) * w_scale), dst->height - bins[i]),
				hist_color, 2, 8, 0);
		}

		//printf("Scale bw: %4.2f pixels per 100 units\r", max_value * 100 / ((float)ImagenHistorial->height));
	} else if (dst->nChannels == 3) {
		IplImage *channelA = cvCreateImage(cvGetSize(dst), IPL_DEPTH_8U, 1);
		IplImage *channelB = cvCreateImage(cvGetSize(dst), IPL_DEPTH_8U, 1);
		IplImage *channelC = cvCreateImage(cvGetSize(dst), IPL_DEPTH_8U, 1);
		cvSplit(dst, channelA, channelB, channelC, NULL);

		size_t mybins[256];
		size_t max_value = 0;
		for (size_t i = 0; i < hist_size; i++) {
			max_value = (bins[i] > max_value) ? bins[i] : max_value;
		}
		for (size_t i = 0; i < binsCount * hist_size; i++) {
			bins[i] /= max_value;
		}
		hist_color = cvScalar(255, 0, 0);
		graficarHistograma(channelA, binsCount, bins);

		hist_color = cvScalar(0, 255, 0);
		graficarHistograma(channelB, binsCount, bins);

		hist_color = cvScalar(0, 0, 255);
		graficarHistograma(channelC, binsCount, bins);

		hist_color = cvScalarAll(255);

		cvReleaseImage(&channelA);
		cvReleaseImage(&channelB);
		cvReleaseImage(&channelC);
	}
}
开发者ID:changeyourdestiny,项目名称:DIP,代码行数:55,代码来源:operateImage.cpp


示例15: test_cvDrawContours

/**
 * Paint all contours with a single OpenCV call on an image.
 */
void test_cvDrawContours( IplImage *img, CvSeq* contours)
{
	IplImage* image_all_contours = cvCreateImage(cvGetSize(img), 8, 1);
	cvCopy(img, image_all_contours, NULL);
//		CvSeq* contour = contours; // first contour
	// TODO need for loop to iterate through sequence
	cvDrawContours( image_all_contours, contours, cvScalarAll(255), cvScalarAll(0), 0, CV_FILLED, 8, cvPoint(0,0));

	cvShowImage( "All contours", image_all_contours);
	cvReleaseImage(&image_all_contours);
}
开发者ID:flair2005,项目名称:RGBDLocalization,代码行数:14,代码来源:test.c


示例16: initKalman

//=========================================
CvKalman* initKalman(CvKalman* kalman) {
//=========================================
	const float A[] = {1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1};
	kalman = cvCreateKalman(4, 2, 0);
	memcpy(kalman->transition_matrix->data.fl, A, sizeof(A));//A
	cvSetIdentity(kalman->measurement_matrix, cvScalarAll(1));//H
	cvSetIdentity(kalman->process_noise_cov, cvScalarAll(1e-5));//Q w ;
	cvSetIdentity(kalman->measurement_noise_cov, cvScalarAll(1e-1));//R v
	cvSetIdentity(kalman->error_cov_post, cvScalarAll(1));//P
	return kalman;
}
开发者ID:miguelao,项目名称:gst_plugins_tsunami,代码行数:12,代码来源:camshift.cpp


示例17: binary

/* Shadow Removal on the basis of Y correction and colour adjustment*/
cv::Mat LaneDetector::shadowRemoval(cv::Mat &img){
    cv::Mat original_image=img;
    int shadow_mean =0, non_shadow_mean =0 ,count_shadow=0,count_non_shadow=0, difference;
    cv::Mat binary(original_image.rows,original_image.cols,CV_8UC1,cvScalarAll(0));
    cv::Mat image_ycrcb(original_image.rows,original_image.cols,CV_8UC3,cvScalarAll(0));
    cv::Mat final(original_image.rows,original_image.cols,CV_8UC3,cvScalarAll(0));
    
    cvtColor(original_image,image_ycrcb,CV_BGR2YCrCb);
    binary = shadowDetection(image_ycrcb);    
    if (debug_mode > 0){
        cv::namedWindow("binary_image",1);
        cv::imshow("binary_image",binary);
        cv::waitKey(20);
    }
    cv::Mat element = cv::getStructuringElement( cv::MORPH_ELLIPSE,
                                       cv::Size( 7,7),
                                       cv::Point( 3, 3) );
    dilate(binary,binary,element);
    element = cv::getStructuringElement( cv::MORPH_ELLIPSE,
                                       cv::Size( 5,5),
                                       cv::Point( 2, 2) );
    erode(binary,binary,element);
    
    if (debug_mode > 0){
        cv::namedWindow("eroded_image",1);
        cv::imshow("eroded_image",binary);
        cv::waitKey(20);
    }
    
    for (int i=0;i<image_ycrcb.rows;i++){
        for (int j=0;j<image_ycrcb.cols;j++){
            if (binary.at<uchar>(i,j)==0){
                shadow_mean += image_ycrcb.at<cv::Vec3b>(i,j)[0];
                count_shadow++;
            }
            else{
                non_shadow_mean += image_ycrcb.at<cv::Vec3b>(i,j)[0];
                count_non_shadow++;
            }
        }
    }
    if (count_shadow != 0){
        difference = non_shadow_mean/count_non_shadow - shadow_mean/count_shadow;
        for (int i=0;i<image_ycrcb.rows;i++){
            for (int j=0;j<image_ycrcb.cols;j++){
                if (binary.at<uchar>(i,j)==0){
                    image_ycrcb.at<cv::Vec3b>(i,j)[0] += difference/2; // Y adjustment
                    image_ycrcb.at<cv::Vec3b>(i,j)[2] -= difference/6; // Colour adjustment
                }
            }
        }
        cvtColor(image_ycrcb,final,CV_YCrCb2BGR);
        return final;
    }
开发者ID:AGV-IIT-KGP,项目名称:eklavya-2015,代码行数:55,代码来源:shadowRemoval.cpp


示例18: cvScalarAll

cv::Mat &RegionMask::QPolygon2Mask(cv::Mat &img, const QPolygon external, const QList<QPolygon> &holes) {
    vector<vector<cv::Point> > points;

    Utils::QPolygon2CvPointArray(external, points);
    cv::fillPoly(img, points, cvScalarAll(255), 4);

    for(const QPolygon& hole : holes){
        Utils::QPolygon2CvPointArray(hole, points);
        cv::fillPoly(img, points, cvScalarAll(0),4 );
    }
    return img;
}
开发者ID:lopespt,项目名称:PhD-Thesis,代码行数:12,代码来源:RegionMask.cpp


示例19: get_contour_points_from_image_with_size

struct point*
get_contour_points_from_image_with_size (const GdkPixbuf *image,
                                         int             *size)
{
  IplImage *ipl_image, *ipl_gray;
  CvMemStorage *contours;
  CvSeq *first_contour;
  CvScalar black, white;
  struct point *result;

  black = cvScalarAll (0);
  white = cvScalarAll (255);

  ipl_image = pixbuf2ipl (image);

  ipl_gray = cvCreateImage (cvGetSize (ipl_image),
                            ipl_image->depth,
                            N_CHANNELS_GRAY);

  cvCvtColor (ipl_image, ipl_gray, CV_BGR2GRAY);
  cvThreshold (ipl_gray, ipl_gray, 127, 255, CV_THRESH_BINARY|CV_THRESH_OTSU);
  cvSmooth (ipl_gray, ipl_gray, CV_GAUSSIAN, 15, 15, 0, 0);

  contours = cvCreateMemStorage (0);
  first_contour = NULL;
  cvFindContours (ipl_gray,
                  contours,
                  &first_contour,
                  sizeof (CvContour),
                  CV_RETR_LIST,
                  CV_CHAIN_APPROX_NONE,
                  cvPoint (0,0));

  result = (struct point*) malloc (sizeof (struct point) * first_contour->total);
  for (int i = 0; i < first_contour->total; ++i)
    {
      CvPoint *contour_point;

      contour_point = CV_GET_SEQ_ELEM (CvPoint, first_contour, i);

      result[i].x = contour_point->x;
      result[i].y = contour_point->y;
    }

  *size = first_contour->total;

  cvReleaseImage (&ipl_image);
  cvReleaseImage (&ipl_gray);
  cvReleaseMemStorage (&contours);

  return result;
}
开发者ID:voyagerok,项目名称:shape-matching,代码行数:52,代码来源:imgproc.c


示例20: p2p4Check

unsigned char p2p4Check(IplImage *source, int i, int j, int k, int l) {
    unsigned char pixelShouldBeDeleted = YES;
    if (cvGet2D(source, i + k, j + l).val[0] == DELETED_PIXEL) {
        pixelShouldBeDeleted = NO;
        cvSet2D(source, i + k, j + l, cvScalarAll(WHITE_PIXEL));
        if (fourthCondition(source, i, j) == YES)
        {
            pixelShouldBeDeleted = YES;
        }
        cvSet2D(source, i+k, j+l, cvScalarAll(DELETED_PIXEL));
    }
    return pixelShouldBeDeleted;
}
开发者ID:LordZepto,项目名称:iOS-Sudoku-Solver,代码行数:13,代码来源:Common.c



注:本文中的cvScalarAll函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cvSeqPush函数代码示例发布时间:2022-05-30
下一篇:
C++ cvRound函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap