当前位置: 首页>>代码示例>>C++>>正文


C++ cv::Size方法代码示例

本文整理汇总了C++中cv::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ cv::Size方法的具体用法?C++ cv::Size怎么用?C++ cv::Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv的用法示例。


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

示例1: setDefaults

void Calibration::setDefaults()
{
	views.n = 0;
	views.prompt = false;
	views.save_views = false;

	find_chessboard.flags = 0;
	find_chessboard.grid = Size(0, 0);

	sub_pixel.win = WIN_SIZE;
	sub_pixel.zz = ZERO_ZNE;
	sub_pixel.crit = ERR_TOL;

	calib_cam.flags = 0;

	solve_pnp.useExtGuess = false;

	polka_dots.dilate = 0;
	polka_dots.erode = 0;
	polka_dots.thr1 = 0;
	polka_dots.thr2 = 0;

	intrinsic_params.file = "";
	extrinsic_params.file = "";
}
开发者ID:JoshMarino,项目名称:lims-hsv-system,代码行数:25,代码来源:Calibration.cpp

示例2: find_in_image

void find_in_image() {
	Setting conf("application.cfg");
	string base = conf.getString("application.res_dir");
	Mat haystack = read(base + "/car_features/01.jpg");
	Mat needle = toGrayscale(cv::imread(base + "/car_features/01.jpg"));
	Mat needle64x128;
	cv::resize(needle, needle64x128, Size(64, 128));

	vector<float> hog = computeHog(needle64x128);

	cout << hog.size() << endl;
}
开发者ID:lolski,项目名称:exercise-hog-opencv-cpp,代码行数:12,代码来源:main.cpp

示例3: resize

 void resize(Mat& img, float fx) {
     Mat dst;
     int inter = (fx > 1.0) ? CV_INTER_CUBIC : CV_INTER_AREA;
     cv::resize(img, dst, Size(), fx, 1.0, inter);
     assert(img.rows == dst.rows);
     if (img.cols > dst.cols) {
         dst.copyTo(img(Range::all(), Range(0, dst.cols)));
         img(Range::all(), Range(dst.cols, img.cols)) = cv::Scalar::all(0);
     } else {
         dst(Range::all(), Range(0, img.cols)).copyTo(img);
     }
 }
开发者ID:Jokeren,项目名称:neon,代码行数:12,代码来源:specgram.hpp

示例4: createBuffer

void EnhancedStereo::createBuffer()
{
//    cout << "create" << endl;
    int bufferWidth = smallWidth()*dispMax;
    if (errorBuffer.cols != bufferWidth or errorBuffer.rows != smallHeight())
    {
        errorBuffer = Mat_<uint8_t>(Size(bufferWidth, smallHeight()));
    }
    if (tableauLeft.cols != bufferWidth or tableauLeft.rows != smallHeight())
    {
        tableauLeft = Mat_<int>(Size(bufferWidth, smallHeight()));
    }
    if (tableauRight.cols != bufferWidth or tableauRight.rows != smallHeight())
    {
        tableauRight = Mat_<int>(Size(bufferWidth, smallHeight()));
    }
    if (tableauTop.cols != bufferWidth or tableauTop.rows != smallHeight())
    {
        tableauTop = Mat_<int>(Size(bufferWidth, smallHeight()));
    }
    if (tableauBottom.cols != bufferWidth or tableauBottom.rows != smallHeight())
    {
        tableauBottom = Mat_<int>(Size(bufferWidth, smallHeight()));
    }
    if (smallDisparity.cols != smallWidth() or smallDisparity.rows != smallHeight())
    {
        smallDisparity = Mat_<uint8_t>(Size(smallWidth(), smallHeight()));
    }
}
开发者ID:libing64,项目名称:visgeom,代码行数:29,代码来源:eucm_stereo.cpp

示例5: process

GaussianMixture* HogPeopleDetector::process(int offsetX=0, int offsetY=0, double scale=1) {

    detectedROI.clear();
    detectedCENTER.clear();
    detectedSCALES.clear();
    detectedIDS.clear();

    //gets the detections
    vector<cv::Rect> rois;
    vector<cv::Point> points;
    HOGDescriptor hogDesc;//the detector
    hogDesc.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());//we use a people detector

    //cv::Mat m (this->imgBank->imgSRC);
    cv::gpu::GpuMat gpuMat(this->imgBank->imgSRC);

    hogDesc.detectMultiScale(gpuMat, rois, 0, Size(8, 8),
                             Size(32,32), 1.05, 2.5);

    //fills the gaussian mixture with detections
    for(int i = 0 ; i < rois.size() ; i++) {
        cv::Rect r = rois[i];
        detectedROI.push_back(r);
        cv::Point p;
        p.x = r.x + r.width*0.5;
        p.y = r.y + r.height*0.5;
        detectedCENTER.push_back(p);
        this->gm->glist[i]->mean[0] = p.x;
        this->gm->glist[i]->mean[1] = p.y;
    }
    this->nbdetected = rois.size();

    gm->curnb = rois.size();
    return gm;

}
开发者ID:elie-moussy,项目名称:LibPF,代码行数:36,代码来源:HogPeopleDetector.cpp

示例6: Start

void FingerTracker::Start()
{
	cvDestroyAllWindows();
	VideoCapture capture(0);
	if (!capture.isOpened())
	{
		throw std::runtime_error("Could not start camera capture");
	}

	Mat frame;
    while (true)
	{
		if (capture.read(frame))
		{
			if (frame.rows && frame.cols)
			{
				flip(frame, frame, 1);
				pyrDown(frame, frame, Size(frame.cols / 2, frame.rows / 2));

				Process(frame);

				auto const& candidate = GetCandidate();

#if ENABLE_LINE_DRAWING
				if (candidate.m_found)
				{
					m_points.push_back(candidate.m_fingerPosition);
				}
				if (m_points.size() > LINE_HISTORY)
				{
					m_points.pop_front();
				}
#endif

				Display(frame, candidate);
			}
		}
					
		auto key = cvWaitKey(10);
		if (char(key) == 27)
		{
			break;
		}
	}
	capture.release();
}
开发者ID:brejski,项目名称:FingerTracking,代码行数:46,代码来源:FingerTracker.cpp

示例7: detect

void DeepPyramid::detect(const Mat &img, vector<BoundingBox> &objects, bool isBoundingBoxRegressor) const {
    CV_Assert(img.channels() == 3);
    vector<FeatureMap> maps;
    cout << "here!" << endl;
    constructFeatureMapPyramid(img, maps);
    cout << "filter" << endl;
    detect(maps, objects);
    cout << "group rectangle" << endl;
    calculateOriginalRectangle(objects, Size(img.cols, img.rows));
    groupRectangle(objects);
    if (isBoundingBoxRegressor) {
        cout << "boundbox regressor: TODO" << endl;
    } else {
        cout << "bounding box regressor switch off" << endl;
    }
    cout << "Object count:" << objects.size() << endl;
}
开发者ID:ByGreez,项目名称:face-detection-model,代码行数:17,代码来源:deep_pyramid.cpp

示例8: computeCost

void EnhancedStereo::computeCost(const Mat_<uint8_t> & img1, const Mat_<uint8_t> & img2)
{
    double T1 = 0, T2 = 0; // time profiling
//    cout << "cost" << endl;
    Mat_<uint8_t> img2remap(Size(blockSize - 1 + dispMax, blockSize));
    Mat_<int> integral1, integral2;
    integral(img1, integral1);
    int blockSize2 = blockSize * blockSize;
    for (int v = 0; v < smallHeight(); v++)
    {
        for (int u = 0; u < smallWidth(); u++)
        {
            int idx = getLinearIdx(vBig(v), uBig(u));
            uint8_t * outPtr = errorBuffer.row(v).data + u*dispMax;
            
            Point pinf = pinfPxVec[idx];
            CurveRasterizer<Polynomial2> raster(pinf.x, pinf.y, epipolePx.x, epipolePx.y, epipolarVec[idx]);
            
            // the remap Mat
            img2remap.setTo(0);
            for (int i = 0; i < img2remap.cols; i++, raster.step())
            {
                int u2 = raster.x + halfBlockSize();
                if (u2 < 0 or u2 >= img2.cols) continue;
                for (int j = -halfBlockSize(); j <= halfBlockSize(); j++)
                {
                    int v2 = raster.y + j;
                    if (v2 < 0 or v2 >= img2.rows) continue;
                    img2remap(halfBlockSize() + j, i) = img2(v2, u2);
                }
            }
            
            //compute bias
            int u1 = uBig(u) - halfBlockSize();
            int v1 = vBig(v) - halfBlockSize();
            int bias1 = integral1(v1, u1) + integral1(v1 + blockSize, u1 + blockSize) -
                         integral1(v1 + blockSize, u1) - integral1(v1, u1 + blockSize);
//            
//            
            integral(img2remap, integral2);
            
            // compute the actual error
            for (int i = 0; i < dispMax; i++, outPtr++)
            {
                int bias = integral2(blockSize, i + blockSize) - integral2(blockSize, i);
                bias = (bias - bias1) / blockSize2;
                bias = min(10, max(-10, bias));
//                cout << bias << " ";
                int acc = 0;
                for (int x2 = -halfBlockSize(); x2 <= halfBlockSize(); x2++)
                {
                    for (int x1 = -halfBlockSize(); x1 <= halfBlockSize(); x1++)
                    {
                        acc += abs(img1(vBig(v) + x2, uBig(u)- x1) - 
                            img2remap(halfBlockSize() + x2, i + halfBlockSize() + x1) + bias);
                    }
                }
                
                *outPtr = acc / blockSize2;
            }
//            cout << endl;
        }
    }
//    cout << "read " << T1 / CLOCKS_PER_SEC << endl;
//    cout << "write " << T2 / CLOCKS_PER_SEC << endl;
} 
开发者ID:libing64,项目名称:visgeom,代码行数:66,代码来源:eucm_stereo.cpp

示例9: getSize

Size Camera::getSize() {
    return Size((int)getWidth(), (int)getHeight());
}
开发者ID:mkkelley,项目名称:videoproc,代码行数:3,代码来源:Camera.cpp

示例10: Setup

void FingerTracker::Setup()
{
	VideoCapture capture(0);
	if (!capture.isOpened())
	{
		throw std::runtime_error("Could not start camera capture");
	}

	int windowSize = 25;
	int Xpos = 200;
	int Ypos = 50;
	int update = 0;
	int buttonClicked = 0;
	namedWindow("RGB", CV_WINDOW_AUTOSIZE);
	createTrackbar("X", "RGB",  &Xpos, 320, TrackBarCallback, (void*)&update);
	createTrackbar("Y", "RGB",  &Ypos, 240, TrackBarCallback, (void*)&update);
	createTrackbar("Size", "RGB",  &windowSize, 100, TrackBarCallback, (void*)&update);
	setMouseCallback("RGB", MouseCallback, (void*)&buttonClicked);
	Mat fingerWindowBackground, fingerWindowBackgroundGray;

	m_calibrationData.reset(new CalibrationData());
	bool ticking = false;
	std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
    while (true)
	{  		
		Mat frame, frameHSV;

		if (capture.read(frame))
		{
			flip(frame, frame, 1);

			pyrDown(frame, frame, Size(frame.cols / 2, frame.rows / 2));

			Rect fingerWindow(Point(Xpos, Ypos), Size(windowSize, windowSize*3));
			if (Xpos + windowSize >= frame.cols || Ypos + windowSize*3 >= frame.rows)
			{
				windowSize = 20;
				Xpos = 200;
				Ypos = 50;
				update = 0;
			}
			else if (buttonClicked == 1)
			{
				frame(fingerWindow).copyTo(fingerWindowBackground);
				cvtColor(fingerWindowBackground, fingerWindowBackgroundGray, CV_BGR2GRAY);
				buttonClicked  = 0;
				update = 0;
				cvDestroyAllWindows();
			}

			if (fingerWindowBackgroundGray.rows && !m_calibrationData->m_ready)
			{
				Mat diff, thd;
				absdiff(frame(fingerWindow), fingerWindowBackground, diff);
				std::vector<Mat> ch;
				split(diff, ch);
				threshold(ch[0], ch[0], m_calibrationDiffThreshold, 255, 0);
				threshold(ch[1], ch[1], m_calibrationDiffThreshold, 255, 0);
				threshold(ch[2], ch[2], m_calibrationDiffThreshold, 255, 0);
				thd = ch[0];
				add(thd, ch[1], thd);
				add(thd, ch[2], thd);
				medianBlur(thd, thd, 5);

				Mat top, middle, bottom;
				Rect r1 = Rect(0, 0, thd.cols, thd.rows/3);
				Rect r2 = Rect(0, thd.rows / 3 + 1, thd.cols, thd.rows/3);
				Rect r3 = Rect(0, thd.rows * 2 / 3 + 1, thd.cols, thd.rows -  thd.rows * 2 / 3 - 1);
				top = thd(r1);
				middle = thd(r2);
				bottom = thd(r3);			

				auto percentageTop = countNonZero(top) * 100.0 / top.size().area();
				auto percentageMiddle = countNonZero(middle) * 100.0 / middle.size().area();
				auto percentageBottom = countNonZero(bottom) * 100.0 / bottom.size().area();

				bool topReady = false;
				bool middleReady = false;
				bool bottomReady = false;

				Scalar c1, c2, c3;
				if (percentageTop > m_calibrationTopLowerThd && percentageTop < m_calibrationTopUpperThd)
				{
					topReady = true;
					c1 = Scalar(0, 255, 255);
				}
				else
				{
					c1 = Scalar(0, 0, 255);
				}

				if (percentageMiddle > m_calibrationMiddleLowerThd && percentageMiddle < m_calibrationMiddleUppperThd)
				{
					middleReady = true;					
					c2 = Scalar(0, 255, 255);
				}
				else
				{
					c2 = Scalar(0, 0, 255);
				}
//.........这里部分代码省略.........
开发者ID:brejski,项目名称:FingerTracking,代码行数:101,代码来源:FingerTracker.cpp

示例11: Process

void FingerTracker::Process(Mat frame)
{
#if ENABLE_DEBUG_WINDOWS
	Mat img_display;
	frame.copyTo(img_display);
#endif
	
	//	Process only Region of Interest i.e. region around current finger position
	Rect roi = Rect(		
		Point(std::max(m_currentCandidate.m_windowRect.tl().x - m_roiSpanX, 0), std::max(m_currentCandidate.m_windowRect.tl().y - m_roiSpanY, 0)), 		
		Point(std::min(m_currentCandidate.m_windowRect.tl().x + m_roiSpanX + m_calibrationData->m_fingerPatch.cols, frame.cols), 
			  std::min(m_currentCandidate.m_windowRect.tl().y + m_roiSpanY + m_calibrationData->m_fingerPatch.rows, frame.rows)));

	Mat frameRoi;
	frame(roi).copyTo(frameRoi);

	//================TEMPLATE MATCHING
	int result_cols =  frameRoi.cols - m_calibrationData->m_fingerPatch.cols + 1;
	int result_rows = frameRoi.rows - m_calibrationData->m_fingerPatch.rows + 1;
	assert(result_cols > 0 && result_rows > 0);

	Mat scoreMap;
	scoreMap.create(result_cols, result_rows, CV_32FC1);

	//	Compare current frame roi region to known candidate
	//	Using OpenCV matchTemplate function with correlation coefficient matching method
	matchTemplate(frameRoi, m_calibrationData->m_fingerPatch, scoreMap, 3);

	//================HISTOGRAM BACK PROJECTION
	MatND backProjection;
	Mat frameHSV;
	cvtColor(frameRoi, frameHSV, CV_BGR2HSV);

	calcBackProject(&frameHSV, 1, m_calibrationData->m_channels, m_calibrationData->m_hist, backProjection, (const float**)(m_calibrationData->m_ranges), 1, true);

	Mat backProjectionThresholded;
	threshold(backProjection, backProjectionThresholded, m_backProjectionThreshold, 255, 0);
	erode(backProjectionThresholded, backProjectionThresholded, getStructuringElement(MORPH_RECT, Size(2 * m_erosionSize + 1, 2 * m_erosionSize + 1), Point(m_erosionSize, m_erosionSize)));
	dilate(backProjectionThresholded, backProjectionThresholded, getStructuringElement(MORPH_RECT, Size(2 * m_dilationSize + 1, 2 * m_dilationSize + 1), Point(m_dilationSize, m_dilationSize)));

	Mat backProjectionThresholdedShifted;
	Rect shifted(Rect(m_calibrationData->m_fingerPatch.cols - 1, m_calibrationData->m_fingerPatch.rows - 1, scoreMap.cols, scoreMap.rows));
	backProjectionThresholded(shifted).copyTo(backProjectionThresholdedShifted);

	Mat maskedOutScoreMap(scoreMap.size(), CV_8U);
	scoreMap.copyTo(maskedOutScoreMap, backProjectionThresholdedShifted);

	//====================Localizing the best match with minMaxLoc
	double minVal; double maxVal; Point minLoc; Point maxLoc;
	Point matchLoc;
	minMaxLoc(maskedOutScoreMap, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
	matchLoc = maxLoc + roi.tl();

	m_currentCandidate.m_confidence = static_cast<float>(maxVal);

	if (maxVal > m_candidateDetecionConfidenceThreshold)
	{
		m_currentCandidate.m_found = true;
		m_currentCandidate.m_windowRect = Rect(matchLoc, Point(matchLoc.x + m_calibrationData->m_fingerPatch.cols , matchLoc.y + m_calibrationData->m_fingerPatch.rows));		

		//================Find finger position
		Mat fingerWindowThresholded;
		backProjectionThresholded(Rect(maxLoc, Point(maxLoc.x + m_calibrationData->m_fingerPatch.cols , maxLoc.y + m_calibrationData->m_fingerPatch.rows))).copyTo(fingerWindowThresholded);
		
		m_currentCandidate.m_fingerPosition = GetFingerTopPosition(fingerWindowThresholded) + matchLoc;

#if ENABLE_DEBUG_WINDOWS
		rectangle(img_display, m_currentCandidate.m_windowRect.tl(), m_currentCandidate.m_windowRect.br(), Scalar(255,0,0), 2, 8, 0 );
		rectangle(scoreMap, m_currentCandidate.m_windowRect.tl(), m_currentCandidate.m_windowRect.br(), Scalar::all(0), 2, 8, 0 );
		rectangle(img_display, m_currentCandidate.m_fingerPosition, m_currentCandidate.m_fingerPosition + Point(5,5), Scalar(255,0,0));
#endif
	}
	else
	{
		m_currentCandidate.m_found = false;
	}

#if ENABLE_DEBUG_WINDOWS
	std::stringstream ss;
	ss << maxVal;
	putText(img_display, ss.str(), Point(50, 50), 0, 0.5, Scalar(255,255,255), 1);

	imshow("Overlays", img_display);
	imshow("Results", scoreMap);
	imshow("ResultMasked", maskedOutScoreMap);
#endif
}
开发者ID:brejski,项目名称:FingerTracking,代码行数:87,代码来源:FingerTracker.cpp

示例12: srcGray

/*
 * Class:     io_github_melvincabatuan_fullbodydetection_MainActivity
 * Method:    predict
 * Signature: (Landroid/graphics/Bitmap;[B)V
 */
JNIEXPORT void JNICALL Java_io_github_melvincabatuan_fullbodydetection_MainActivity_predict
  (JNIEnv * pEnv, jobject clazz, jobject pTarget, jbyteArray pSource){

   AndroidBitmapInfo bitmapInfo;
   uint32_t* bitmapContent; // Links to Bitmap content

   if(AndroidBitmap_getInfo(pEnv, pTarget, &bitmapInfo) < 0) abort();
   if(bitmapInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) abort();
   if(AndroidBitmap_lockPixels(pEnv, pTarget, (void**)&bitmapContent) < 0) abort();

   /// Access source array data... OK
   jbyte* source = (jbyte*)pEnv->GetPrimitiveArrayCritical(pSource, 0);
   if (source == NULL) abort();

   /// cv::Mat for YUV420sp source and output BGRA 
    Mat srcGray(bitmapInfo.height, bitmapInfo.width, CV_8UC1, (unsigned char *)source);
    Mat mbgra(bitmapInfo.height, bitmapInfo.width, CV_8UC4, (unsigned char *)bitmapContent);

/***********************************************************************************************/
    /// Native Image Processing HERE... 
    if(DEBUG){
      LOGI("Starting native image processing...");
    }

    if (full_body_cascade.empty()){
       t = (double)getTickCount();
       sprintf( full_body_cascade_path, "%s/%s", getenv("ASSETDIR"), "haarcascade_fullbody.xml");       
    
      /* Load the face cascades */
       if( !full_body_cascade.load(full_body_cascade_path) ){ 
           LOGE("Error loading cat face cascade"); 
           abort(); 
       };

       t = 1000*((double)getTickCount() - t)/getTickFrequency();
       if(DEBUG){
       LOGI("Loading full body cascade took %lf milliseconds.", t);
     }
    }
            
 
     std::vector<Rect> fbody;


       //-- Detect full body
       t = (double)getTickCount();
 
       /// Detection took cat_face_cascade.detectMultiScale() time = 655.334471 ms
      // cat_face_cascade.detectMultiScale( srcGray, faces, 1.1, 2 , 0 , Size(30, 30) ); // Scaling factor = 1.1;  minNeighbors = 2 ; flags = 0; minimumSize = 30,30

      // cat_face_cascade.detectMultiScale() time = 120.117185 ms
      // cat_face_cascade.detectMultiScale( srcGray, faces, 1.2, 3 , 0 , Size(64, 64));

 
      
      full_body_cascade.detectMultiScale( srcGray, fbody, 1.2, 2 , 0 , Size(14, 28));  // Size(double width, double height) 

      // scalingFactor parameters determine how much the classifier will be scaled up after each run.
      // minNeighbors parameter specifies how many positive neighbors a positive face rectangle should have to be considered a possible match; 
      // when a potential face rectangle is moved a pixel and does not trigger the classifier any more, it is most likely that it’s a false positive. 
      // Face rectangles with fewer positive neighbors than minNeighbors are rejected. 
      // If minNeighbors is set to zero, all potential face rectangles are returned. 
      // The flags parameter is from the OpenCV 1.x API and should always be 0. 
      // minimumSize specifies the smallest face rectangle we’re looking for. 

       t = 1000*((double)getTickCount() - t)/getTickFrequency();
       if(DEBUG){
          LOGI("full_body_cascade.detectMultiScale() time = %lf milliseconds.", t);
      }


       // Iterate through all faces and detect eyes
       t = (double)getTickCount();

       for( size_t i = 0; i < fbody.size(); i++ )
       {
          Point center(fbody[i].x + fbody[i].width / 2, fbody[i].y + fbody[i].height / 2);
          ellipse(srcGray, center, Size(fbody[i].width / 2, fbody[i].height / 2), 0, 0, 360, Scalar(255, 0, 255), 4, 8, 0);
       }//endfor
  
       t = 1000*((double)getTickCount() - t)/getTickFrequency();
       if(DEBUG){
          LOGI("Iterate through all faces and detecting eyes took %lf milliseconds.", t);
       }

       /// Display to Android
       cvtColor(srcGray, mbgra, CV_GRAY2BGRA);


      if(DEBUG){
        LOGI("Successfully finished native image processing...");
      }
   
/************************************************************************************************/ 
   
//.........这里部分代码省略.........
开发者ID:DeLaSalleUniversity-Manila,项目名称:FullBodyDetection,代码行数:101,代码来源:ImageProcessing.cpp

示例13: open_imgs_dir

void open_imgs_dir(const char* dir_name, std::vector<cv::Mat>& images, std::vector<std::string>& images_names, double downscale_factor) {
	if (dir_name == NULL) {
		return;
	}

	string dir_name_ = string(dir_name);
	vector<string> files_;

#ifndef WIN32
//open a directory the POSIX way

	DIR *dp;
	struct dirent *ep;     
	dp = opendir (dir_name);
	
	if (dp != NULL)
	{
		while ((ep = readdir (dp))) {
			if (ep->d_name[0] != '.')
				files_.push_back(ep->d_name);
		}
		
		(void) closedir (dp);
	}
	else {
		cerr << ("Couldn't open the directory");
		return;
	}

#else
//open a directory the WIN32 way
	HANDLE hFind = INVALID_HANDLE_VALUE;
	WIN32_FIND_DATA fdata;

	if(dir_name_[dir_name_.size()-1] == '\\' || dir_name_[dir_name_.size()-1] == '/') {
		dir_name_ = dir_name_.substr(0,dir_name_.size()-1);
	}

	hFind = FindFirstFile(string(dir_name_).append("\\*").c_str(), &fdata);	
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (strcmp(fdata.cFileName, ".") != 0 &&
				strcmp(fdata.cFileName, "..") != 0)
			{
				if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{
					continue; // a diretory
				}
				else
				{
					files_.push_back(fdata.cFileName);
				}
			}
		}
		while (FindNextFile(hFind, &fdata) != 0);
	} else {
		cerr << "can't open directory\n";
		return;
	}

	if (GetLastError() != ERROR_NO_MORE_FILES)
	{
		FindClose(hFind);
		cerr << "some other error with opening directory: " << GetLastError() << endl;
		return;
	}

	FindClose(hFind);
	hFind = INVALID_HANDLE_VALUE;
#endif
	
	for (unsigned int i=0; i<files_.size(); i++) {
		if (files_[i][0] == '.' || !(hasEndingLower(files_[i],"jpg")||hasEndingLower(files_[i],"png"))) {
			continue;
		}
		cv::Mat m_ = cv::imread(string(dir_name_).append("/").append(files_[i]));
		if(downscale_factor != 1.0)
			cv::resize(m_,m_,Size(),downscale_factor,downscale_factor);
		images_names.push_back(files_[i]);
		images.push_back(m_);
	}
		

}
开发者ID:berak,项目名称:SfM-Toy-Library,代码行数:86,代码来源:load_file.cpp

示例14: main


//.........这里部分代码省略.........
    {
        cout << static_cast<int>(id) << " ";
    }
    cout << endl;

    for (const auto &id : ids)
    {
        vector<uint8_t> raw;
        PacketType type;

        cout << "examining " << static_cast<int>(id) << endl;

        for (const auto &pkt : pkts)
        {
            if (pkt.getID() == id)
            {
                size_t new_length = pkt.getOffset() +
                    static_cast<size_t>(pkt.getLength());

                type = pkt.getType();

                if (new_length > raw.size())
                {
                    raw.resize(new_length, 0);
                }

                for (size_t k = 0; k < pkt.getLength(); k++)
                {
                    raw[pkt.getOffset() + k] = pkt.getData()[k];
                }
            }
        }

        cout << "type: " << type << endl;

        cout << hex;
        for (size_t j = 0; j < 512; j++)
        {
            if (j > 0 && (j % 32) == 0)
            {
                cout << endl;
            }
            cout << (static_cast<unsigned int>(raw[j]) & 0xFF) << " ";
        }
        cout << endl;

        Mat img{Size(160, 120), CV_8UC3, raw.data()};
        Mat dst;

        //cvtColor(img, dst, CV_YUV2GRAY_UYVY);
        //cvtColor(img, dst, CV_YUV2GRAY_YUY2);
        //cvtColor(img, dst, CV_YUV2BGR_UYVY);
        //cvtColor(img, dst, CV_YUV2BGRA_UYVY);
        //cvtColor(img, dst, CV_YUV2BGR_YUY2);
        //cvtColor(img, dst, CV_YUV2BGR_YVYU);
        //cvtColor(img, dst, CV_YUV2BGRA_YUY2);
        //cvtColor(img, dst, CV_YUV2BGRA_YVYU);
        //cvtColor(img, dst, CV_YUV2GRAY_NV12);
        //cvtColor(img, dst, CV_YUV2BGR_NV12);
        cvtColor(img, dst, CV_YCrCb2BGR);

        imshow("Police Video", dst);
        waitKey(0);

        ofstream out_jpeg{"out.jpg", ofstream::binary};
        for (size_t j = 0; j < raw.size(); j++)
        {
            if (raw[j] == 0xFF && raw[j + 1] == 0xD8)
            {
                cout << "hit the start" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                j++;
            }
            else if (raw[j] == 0xFF && raw[j + 1] == 0xDB)
            {
                cout << "hit the start 2" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                j++;
            }
            else if (raw[j] == 0xFF && raw[j + 1] == 0xC0)
            {
                cout << "hit the start 3" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                j++;
            }
            else if (raw[j] == 0xFF && raw[j + 1] == 0xD9)
            {
                cout << "hit the end" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                return 0;
            }
            else
            {
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 1);
            }
        }
    }

    return 0;
}
开发者ID:alexjlaberge,项目名称:473BodyCam,代码行数:101,代码来源:examine.cpp


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