Example #1
0
/*
 * Class:     com_nekomeshi312_stabcam_StabCameraViewFragment
 * Method:    stopStabilize
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_com_nekomeshi312_stabcam_StabCameraViewFragment_stopStabilize
(JNIEnv *jenv, jobject jobj)
{
	LOGI("stopStabilize");
	gGrayPrev.release();
	gGrayCur.release();
	gRGBACur.release();
	gAffine.release();
#ifdef USE_POC
	gHann.release();
#endif
}
void load_calibration_data(const std::string &file_name, cv::Mat &intrinsics_common, cv::Mat &distortion_vector)
{
	if (file_name.empty()) return;

	intrinsics_common.release();
	distortion_vector.release();

	cv::FileStorage fs;
	if(fs.open(file_name, cv::FileStorage::READ | cv::FileStorage::FORMAT_XML, "utf8")) {
		fs["camera_distortion"] >> distortion_vector;
		fs["camera_intrinsics"] >> intrinsics_common;
		fs.release();
	} else {
Example #3
0
void CMySharkML::GetPredictionLabelandConfidence(std::vector<int> &predictLable, cv::Mat &predictConf, Data<RealVector> &predictions)
{
	predictLable.clear();
	predictConf.release();

	std::size_t numElements = predictions.numberOfElements();

	predictLable.assign(numElements, 0);
	predictConf = cv::Mat(numElements, m_numLabels, CV_32F);
	memset(predictConf.data, 0, sizeof(float)*numElements*m_numLabels);

	for(int k = 0; k < numElements; ++k) {

		predictions.element(k);

		RealVector::iterator iter_p = predictions.element(k).begin(); //Predict.begin();
		float maxP = *iter_p;
		int L = 0;
		predictConf.at<float>(k, 0) = *iter_p;

		std::size_t numInputs = predictions.element(k).size(); //Predict.size();
		for(int i=1; i<numInputs; ++i){
			iter_p++;

			predictConf.at<float>(k, i) = *iter_p;
			if(*iter_p > maxP) {
				maxP = *iter_p;
				L = i;
			}
		}

		predictLable[k] = L;
	}
}
Example #4
0
bool CvMongoMat::download(cv::Mat &image)
{
    image.release();

    if (conn_ == NULL) return false;

    std::auto_ptr<mongo::DBClientCursor> cursor;
    cursor = conn_->query(collection_, QUERY(key_ << BSON("$exists" << true)));

    if (cursor->more() == false) {
        // notiong to do...
        return true;
    }

    mongo::BSONObj obj = cursor->next();
    timestamp_ = obj["timestamp"].Long();

    int len;
    uchar *data = (uchar*)obj[key_].binData(len);
    if (len == 0) return true;

    std::vector<uchar> v(data, data+len);
    image = cv::imdecode(cv::Mat(v), -1);

    return true;
}
Example #5
0
void FORB::toMat32F(const std::vector<TDescriptor> &descriptors, 
  cv::Mat &mat)
{
  if(descriptors.empty())
  {
    mat.release();
    return;
  }
  
  const size_t N = descriptors.size();
  
  mat.create(N, FORB::L*8, CV_32F);
  float *p = mat.ptr<float>();
  
  for(size_t i = 0; i < N; ++i)
  {
    const int C = descriptors[i].cols;
    const unsigned char *desc = descriptors[i].ptr<unsigned char>();
    
    for(int j = 0; j < C; ++j, p += 8)
    {
      p[0] = (desc[j] & (1 << 7) ? 1 : 0);
      p[1] = (desc[j] & (1 << 6) ? 1 : 0);
      p[2] = (desc[j] & (1 << 5) ? 1 : 0);
      p[3] = (desc[j] & (1 << 4) ? 1 : 0);
      p[4] = (desc[j] & (1 << 3) ? 1 : 0);
      p[5] = (desc[j] & (1 << 2) ? 1 : 0);
      p[6] = (desc[j] & (1 << 1) ? 1 : 0);
      p[7] = desc[j] & (1);
    }
  } 
}
static void calculateFeaturesFromInput( cv::Mat imageData, std::vector< float >& featureVector, cv::HOGDescriptor& hog )
{
	std::vector< cv::Point > locations;
	hog.compute( imageData, featureVector, winStride, trainingPadding, locations );

	imageData.release();
}
int VirtualCamera::loadMatrix(cv::Mat &matrix,int rows,int cols ,std::string file)
{

	std:: ifstream in1; 
	in1.open(file.c_str());
	
	//if(in1==NULL) //Yang
	if (in1.fail())
	{
		std::cout<<"Error loading file "<<file.c_str()<<"\n";
		return -1;

	}

	if(!matrix.empty())
		matrix.release();

	matrix=cv::Mat(rows, cols, CV_32F);

	for(int i=0; i<rows; i++)
	{
		for(int j=0; j<cols; j++)
		{
			float val;
			in1>>val;

			Utilities::matSet2D(matrix,j,i,val);

		}
	}
	return 1;
}
bool VideoCapture::retrieve(cv::Mat& image, int channel){
	if(cam_interface.empty()){
		image.release();
		return false;
	}
	return cam_interface[0]->retrieve(image,channel);
}
Example #9
0
PTS32 _cvtColor2BGR(PTU8* pPixels, PTS32 nWidth, PTS32 nHeight, PTImageFormatEnum eFormat, cv::Mat& bgrMat)
{
    if(pPixels == NULL || nWidth < 0 || nHeight < 0) {
        PTDEBUG("%s: Invalid parameters, pPixels[%p], nWidth[%d], nHeight[%d]\n", __FUNCTION__, pPixels, nWidth, nHeight);
        return PT_RET_INVALIDPARAM;
    }

    if(eFormat != PT_IMG_BGR888 && eFormat != PT_IMG_RGBA8888 && eFormat != PT_IMG_ARGB8888 && eFormat != PT_IMG_BGRA8888) {
        PTDEBUG("%s: picture format[%d], ie[%s] not supported!\n",__FUNCTION__, (int)eFormat, strImageFormat[eFormat]);
        return PT_RET_INVALIDPARAM;
    }

    bgrMat.release();

    PTU8* pBuffer = NULL;
    if(eFormat == PT_IMG_ARGB8888) {
        pBuffer = (PTU8*) malloc(3*nWidth*nHeight);//buffer for BGR
        if(pBuffer == NULL) {
            PTDEBUG("%s: no enough memory to support format[%s]\n", __FUNCTION__, strImageFormat[eFormat]);
            return PT_RET_NOMEM;
        }
    }

    switch(eFormat) {
    case PT_IMG_BGR888   : {
        bgrMat = cv::Mat(nHeight, nWidth, CV_8UC3, pPixels);
    }
    break;
    case PT_IMG_RGBA8888 : {
        cvtColor(cv::Mat(nHeight, nWidth, CV_8UC4, pPixels), bgrMat, CV_RGBA2BGR);
    }
    break;
    case PT_IMG_ARGB8888 : {
        const int nSrcChannel = 4;
        const int nDstChannel = 3;
        const int nPixels = nHeight*nWidth;
        PTU8* pSrcBuffer = pPixels;
        PTU8* pDstBuffer = pBuffer;
        for(int i = 0; i < nPixels; i++) {
            pDstBuffer[2] = pSrcBuffer[1];//R
            pDstBuffer[1] = pSrcBuffer[2];//G
            pDstBuffer[0] = pSrcBuffer[3];//B
            pSrcBuffer += nSrcChannel;
            pDstBuffer += nDstChannel;
        }
        bgrMat = cv::Mat(nHeight, nWidth, CV_8UC3, pBuffer);
    }
    break;
    case PT_IMG_BGRA8888 : {
        cvtColor(cv::Mat(nHeight, nWidth, CV_8UC4, pPixels), bgrMat, CV_BGRA2BGR);
    }
    break;
    default : {
        PTDEBUG("%s: picture format[%d], ie[%s] not supported!\n", __FUNCTION__, (int)eFormat, strImageFormat[eFormat]);
        return PT_RET_INVALIDPARAM;
    }
    break;
    }
    return PT_RET_OK;
}
void CallBackFunc(int evnt, int x, int y, int flags, void* userdata) {
	if (evnt == cv::EVENT_LBUTTONDOWN) {
		mouseButtonDown = true;
		targetSelected = false;
		boundingRect = cv::Rect(0,0,0,0);
		point1 = cv::Point(x,y);
		cv::destroyWindow(targetName);
		cv::destroyWindow(ColorTracker.getColorSquareWindowName());
		targetImage.release();
	}
	if (evnt == cv::EVENT_MOUSEMOVE) {
		if (x < 0) x = 0;
		else if (x > image.cols) x = image.cols;
		if (y < 0) y = 0;
		else if (y > image.rows) y = image.rows;
		point2 = cv::Point(x,y);
		if (mouseButtonDown) {
			boundingRect = cv::Rect(point1,point2);
		}
		cv::imshow(imageName,image);
	}
	if (evnt == cv::EVENT_LBUTTONUP) {
		mouseButtonDown = false;
		if (boundingRect.area() != 0) {
			targetImage = image(calibratedRect(boundingRect));
			cv::imshow(targetName, targetImage);
		}
		else {
			boundingRect = cv::Rect(point1-cv::Point(5,5),point1+cv::Point(5,5));
			targetImage = image(calibratedRect(boundingRect));
			cv::imshow(targetName, targetImage);
		}
		targetSelected = true;
    }
}
Example #11
0
void FileUtils::loadDescriptorsFromZippedBin(const std::string& filename,
		cv::Mat& descriptors) {

	std::ifstream zippedFile;
	boost::iostreams::filtering_istream is;

	// Open file
	zippedFile.open(filename.c_str(), std::fstream::in | std::fstream::binary);

	// Check file
	if (zippedFile.good() == false) {
		throw std::runtime_error(
				"Unable to open file [" + filename + "] for reading");
	}

	// Obtain uncompressed file size
	zippedFile.seekg(-sizeof(int), zippedFile.end);
	int fileSize = -1;
	zippedFile.read((char*) &fileSize, sizeof(int));
	zippedFile.seekg(0, zippedFile.beg);

	try {
		is.push(boost::iostreams::gzip_decompressor());
		is.push(zippedFile);

		// Read rows byte
		int rows = -1;
		is.read((char*) &rows, sizeof(int));

		// Read columns byte
		int cols = -1;
		is.read((char*) &cols, sizeof(int));

		// Read type byte
		int type = -1;
		is.read((char*) &type, sizeof(int));

		// Compute data stream size
		long dataStreamSize = fileSize - 3 * sizeof(int);

		descriptors.release();
		descriptors = cv::Mat();
		if (type != CV_32F && type != CV_8U) {
			throw std::runtime_error("Invalid descriptors type");
		}
		descriptors.create(rows, cols, type);

		// Read data bytes
		is.read((char*) descriptors.data, dataStreamSize);

	} catch (const boost::iostreams::gzip_error& e) {
		throw std::runtime_error(
				"Got error while reading file [" + std::string(e.what()) + "]");
	}

	// Close file
	zippedFile.close();

}
Example #12
0
bool kfusion::OpenNISource::grab(cv::Mat& depth, cv::Mat& color)
{
    Status rc = STATUS_OK;

    if (impl_->has_depth)
    {
      rc = impl_->depthStream.readFrame(&impl_->depthFrame);
      if (rc != openni::STATUS_OK)
      {
        sprintf (impl_->strError, "Frame grab failed: %s\n", openni::OpenNI::getExtendedError() );
        REPORT_ERROR (impl_->strError);
      }

      const void* pDepth = impl_->depthFrame.getData();
      int x = impl_->depthFrame.getWidth();
      int y = impl_->depthFrame.getHeight();
      cv::Mat(y, x, CV_16U, (void*)pDepth).copyTo(depth);
    }
    else
    {
        depth.release();
        printf ("no depth\n");
    }

    if (impl_->has_image)
    {
      rc = impl_->colorStream.readFrame(&impl_->colorFrame);
      if (rc != openni::STATUS_OK)
      {
        sprintf (impl_->strError, "Frame grab failed: %s\n", openni::OpenNI::getExtendedError() );
        REPORT_ERROR (impl_->strError);
      }

      const void* pColor = impl_->colorFrame.getData();
      int x = impl_->colorFrame.getWidth();
      int y = impl_->colorFrame.getHeight();
      cv::Mat(y, x, CV_8UC3, (void*)pColor).copyTo(color);
    }
    else
    {
        color.release();
        printf ("no color\n");
    }

    return impl_->has_image || impl_->has_depth;
}
Example #13
0
// Create a function which manages a clean "CTRL+C" command -> sigint command
void sigint_handler(int dummy)
{
    ROS_INFO("- detect-human-face is shutting down...\n");
    
    // Liberation de l'espace memoire
    cv::destroyWindow("Initial");
    cv::destroyWindow("final");
    cv::destroyWindow("diffImg");
    
    prevImg.release();
    currImg.release();
    
    cvReleaseHaarClassifierCascade(&cascade);
    cvReleaseMemStorage(&storage);
    
    ROS_INFO("\n\n... Bye bye !\n   -Manu\n");
    exit(EXIT_SUCCESS); // Shut down the program
}
bool DeckLinkCapture::read(cv::Mat& videoFrame)
{
    if (grab())
        return retrieve(videoFrame);
    else {
        videoFrame.release();
        return false;
    }
}
void spectralFiltering::getResult(cv::Mat &img)
{
    if(originImg.empty())
        return;
    std::vector<cv::Mat> imageR(channel), imageI(channel);
    #pragma omp parallel for
    for(int k = 0;k < channel; k++)
    {
        imageR[k] = spectral[k].real.clone();
        imageI[k] = spectral[k].imag.clone();
        moveSpectral2Center(imageR[k]);
        moveSpectral2Center(imageI[k]);
    }

    if(originImg.type()==CV_8UC3 && colorMode)
    {
        std::vector<cv::Mat> temp(channel);
        #pragma omp parallel for
        for(int k = 0;k < channel; k++)
        {
            if(GHPF)
                iFFT2DHomo(imageR[k], imageI[k], temp[k], originImg.size().width, originImg.size().height);
            else
                iFFT2D(imageR[k], imageI[k], temp[k], originImg.size().width, originImg.size().height);
        }
        img.release();
        cv::merge(temp, img);
    }
    else
    {
        if(GHPF)
            iFFT2DHomo(imageR[0], imageI[0], img, originImg.size().width, originImg.size().height);
        else
            iFFT2D(imageR[0], imageI[0], img, originImg.size().width, originImg.size().height);
    }
    /*
    if(originImg.type()==CV_8UC3 && colorMode)
    {
        cv::Mat temp;
        iFFT2D(imageR, imageI, temp, originImg.size().width, originImg.size().height);
        int j, i;
        #pragma omp parallel for private(i)
        for(j = 0; j < temp.rows; j++)
        {
            for(i = 0; i < temp.cols; i++)
            {
                HSV.at<cv::Vec3f>(j,i)[2] = temp.at<uchar>(j,i);
            }
        }
        myCvtColor(HSV, img, HSV2BGR);
    }
    else
    {
        iFFT2D(imageR, imageI, img, originImg.size().width, originImg.size().height);
    }*/

}
Example #16
0
//analysis operator: action analyse; takes the phase signal and gives the sequence of coefficients (representation realm)
//from phase signal space to zernike representation
void Zernike::analyse(const cv::Mat& sig, cv::Mat& z_coeffs)
{
  z_coeffs.release();
  for(cv::Mat z_j : base_)
  {
    double l2 = cv::norm(z_j, cv::NORM_L2);
    double inner_prod = z_j.dot(sig)/(l2*l2);
    z_coeffs.push_back( inner_prod );
  }
}
Example #17
0
bool vm::scanner::OpenNISource::grab(cv::Mat& depth, cv::Mat& image)
{
  XnStatus rc = XN_STATUS_OK;

  rc = impl_->context.WaitAndUpdateAll ();
  if (rc != XN_STATUS_OK)
      return printf ("Read failed: %s\n", xnGetStatusString (rc)), false;

  if (impl_->has_depth)
  {
    impl_->depth.GetMetaData (impl_->depthMD);
    const XnDepthPixel* pDepth = impl_->depthMD.Data ();
    int x = impl_->depthMD.FullXRes ();
    int y = impl_->depthMD.FullYRes ();
    cv::Mat(y, x, CV_16U, (void*)pDepth).copyTo(depth);
  }
  else
  {
    depth.release();
    printf ("no depth\n");
  }

  if (impl_->has_image)
  {
    impl_->image.GetMetaData (impl_->imageMD);
    const XnRGB24Pixel* pImage = impl_->imageMD.RGB24Data ();
    int x = impl_->imageMD.FullXRes ();
    int y = impl_->imageMD.FullYRes ();
    image.create(y, x, CV_8UC3);

    cv::Vec3b *dptr = image.ptr<cv::Vec3b>();
    for(size_t i = 0; i < image.total(); ++i)
      dptr[i] = cv::Vec3b(pImage[i].nBlue, pImage[i].nGreen, pImage[i].nRed);
  }
  else
  {
    image.release();
    printf ("no image\n");
  }

  return impl_->has_image || impl_->has_depth;
}
Example #18
0
void release_mat_memory()
{
	background_color.release();
	background_color_resize.release();
	raw_color.release();
	absdiff_color.release();
	absdiff_gray.release();
	absdiff_binary.release();
	markers.release();
}
void read_heatmap(double * heatmap_array, int heatmap_index, cv::Mat& heatmap_mat)
{
	heatmap_mat.release();
	heatmap_mat.create(HEAT_SZ, HEAT_SZ, CV_32FC1);
	for (int i = 0; i < HEAT_SZ; ++i)
	{
		for (int j = 0; j < HEAT_SZ; ++j)
		{
			heatmap_mat.at<float>(i, j) = heatmap_array[heatmap_index + i*HEAT_SZ + j];
		}
	}
}
bool DeckLinkCapture::retrieve(cv::Mat& videoFrame)
{	
    if (! deckLinkInputCallback_ || !grabbedVideoFrame_) {
        videoFrame.release();
        return false;
    }
    
    bool status = deckLinkVideoFrameToCvMat(grabbedVideoFrame_, videoFrame);
    
	BOOST_LOG_TRIVIAL(info) << "Video Status: "
		  		<< status
		  		<< std::endl;

    if (!status) {
        error_ = E_FAIL;
        errorString_ = "Error converting the image format.";
        videoFrame.release();
        return false;
    }
    return true;
}
Example #21
0
void Shape::ToTransMat(cv::Mat& dstTransMat)
{
	dstTransMat.release();
	dstTransMat.create(m_Shape.size(), 3, LBF_MAT_TYPE);
	for (int i = 0; i < dstTransMat.rows; i++)
	{
		dstTransMat.at<LBF_DATA>(i, 0) = m_Shape[i].x;
		dstTransMat.at<LBF_DATA>(i, 1) = m_Shape[i].y;
		dstTransMat.at<LBF_DATA>(i, 2) = 1;
	}
	return;
}
Example #22
0
// 画像を読み込んで値を0.0f〜1.0fの範囲に変換
Waifu2x::eWaifu2xError Waifu2x::LoadMat(cv::Mat &float_image, const uint32_t* source, int width, int height)
{
	float_image = cv::Mat(cv::Size(width, height), CV_MAKETYPE(CV_8U, 4));

	const auto LinePixel = float_image.step1() / float_image.channels();
	const auto Channel = float_image.channels();
	const auto Width = float_image.size().width;
	const auto Height = float_image.size().height;

	const uint8_t *sptr = (const uint8_t *)source;
	auto ptr = float_image.data;
	for (int i = 0; i < height; i++)
	{
		for (int j = 0; j < width; j++)
		{
			for (int ch = 0; ch < Channel; ch++)
				ptr[(i * LinePixel + j) * 4 + ch] = sptr[(i * width + j) * 4 + ch];
		}
	}

	// RGBだからBGRに変換
	/*
	for (int i = 0; i < height; i++)
	{
		for (int j = 0; j < width; j++)
			std::swap(ptr[(i * LinePixel + j) * 4 + 0], ptr[(i * LinePixel + j) * 4 + 2]);
	}
	*/

	cv::Mat convert;
	float_image.convertTo(convert, CV_32F, 1.0 / 255.0);
	float_image.release();

	{
		// アルファチャンネル付きだったらα乗算済みにする

		std::vector<cv::Mat> planes;
		cv::split(convert, planes);

		cv::Mat w = planes[3];

		planes[0] = planes[0].mul(w);
		planes[1] = planes[1].mul(w);
		planes[2] = planes[2].mul(w);

		cv::merge(planes, convert);
	}

	float_image = convert;

	return eWaifu2xError_OK;
}
Example #23
0
File: LBSP.cpp Project: caomw/litiv
void LBSP::computeImpl(const cv::Mat& oImage, std::vector<cv::KeyPoint>& voKeypoints, cv::Mat& oDescriptors) const {
    CV_Assert(!oImage.empty());
    cv::KeyPointsFilter::runByImageBorder(voKeypoints,oImage.size(),PATCH_SIZE/2);
    cv::KeyPointsFilter::runByKeypointSize(voKeypoints,std::numeric_limits<float>::epsilon());
    if(voKeypoints.empty()) {
        oDescriptors.release();
        return;
    }
    if(m_bOnlyUsingAbsThreshold)
        lbsp_computeImpl(oImage,m_oRefImage,voKeypoints,oDescriptors,true,m_nThreshold);
    else
        lbsp_computeImpl(oImage,m_oRefImage,voKeypoints,oDescriptors,true,m_fRelThreshold,m_nThreshold);
}
Example #24
0
void FileUtils::loadDescriptorsFromBin(const std::string& filename,
		cv::Mat& descriptors) {

	std::ifstream is;

	// Open file
	is.open(filename.c_str(), std::fstream::in | std::fstream::binary);

	// Check file
	if (is.good() == false) {
		throw std::runtime_error(
				"Unable to open file [" + filename + "] for reading");
	}

	// Obtain uncompressed file size
	is.seekg(0, is.end);
	int fileSize = is.tellg();
	is.seekg(0, is.beg);

	// Read rows byte
	int rows = -1;
	is.read((char*) &rows, sizeof(int));

	// Read columns byte
	int cols = -1;
	is.read((char*) &cols, sizeof(int));

	// Read type byte
	int type = -1;
	is.read((char*) &type, sizeof(int));

	// Check type
	if (type != CV_32F && type != CV_8U) {
		throw std::runtime_error("Invalid descriptors type");
	}

	// Compute data stream size
	long dataStreamSize = fileSize - 3 * sizeof(int);

	// Allocate memory to contain the data bytes
	descriptors.release();
	descriptors = cv::Mat();
	descriptors.create(rows, cols, type);

	// Read data bytes
	is.read((char*) descriptors.data, dataStreamSize);

	// Close file
	is.close();

}
bool C920Camera::RetrieveMat(cv::Mat &image) {
    IplImage* _img = this->RetrieveFrame(this->capture);
    if (!_img) {
        image.release();
        return false;
    }
    if (_img->origin == IPL_ORIGIN_TL)
        cv::Mat(_img).copyTo(image);
    else {
        cv::Mat temp(_img);
        cv::flip(temp, image, 0);
    }
    return true;
}
ImgType copy_cvmat_to_dlib_mat(cv::Mat &input, bool release_after_copy = true)
{
    static_assert(std::is_class<ImgType>::value, "ImgType should be a class");

    using pixel_type = typename dlib::image_traits<ImgType>::pixel_type;
    cv_image<pixel_type> cimg(input);
    ImgType output;
    dlib::assign_image(output, cimg);
    if(release_after_copy){
        input.release();
    }

    return output;
}
void histogram_generator_eyes::compute_histogram(cv::Mat& image, cv::Mat& histogram){

    //Releasing the memory
    histogram.release();

    //Mat aux individual descriptor
    cv::Mat aux_descriptors;
    cv::Mat aux_histogram;
    cv::Mat aux_histogram2;

    //Aux info to compute the boxes
    int aux_cols;
    int aux_rows;
    //Boxes
    std::vector<box> boxes;

    //Cropped aux image
    cv::Mat cropped_image;

    //getting the size of the image
    aux_cols=image.cols;
    aux_rows=image.rows;

    //Getting the boxes

    std::vector<int> binx;
    std::vector<int> biny;
    binx.push_back(1);
    biny.push_back(1);
    boxes=generateSpatialBoxes(aux_rows, aux_cols, binx , biny);


    //Crop the images and extraction features
    for(unsigned int j=0;j<boxes.size();j++){

        cropped_image= image(cv::Range(boxes.at(j).minY, boxes.at(j).maxY), cv::Range(boxes.at(j).minX, boxes.at(j).maxX));
        aux_descriptors=feature_extract->extract_dsift(cropped_image,2,4);
        aux_histogram2=clustering->get_histogram(aux_descriptors);

        transpose(aux_histogram2, aux_histogram2);
        aux_histogram.push_back(aux_histogram2);

    }

    transpose(aux_histogram, aux_histogram);
    histogram.push_back(aux_histogram);
    aux_histogram.release();

}
//! Read cv::Mat from binary
void readMatBinary(std::ifstream& ifs, cv::Mat& in_mat)
{
	if(!ifs.is_open()){
		throw new orArgException("Not opened");
	}
	
	int rows, cols, type;
	ifs.read((char*)(&rows), sizeof(int));
	ifs.read((char*)(&cols), sizeof(int));
	ifs.read((char*)(&type), sizeof(int));

	in_mat.release();
	in_mat.create(rows, cols, type);
	ifs.read((char*)(in_mat.data), in_mat.elemSize() * in_mat.total());
}
Example #29
0
void shuffleRows(const cv::Mat &matrix, cv::Mat& shuffleMatrix)
{
  shuffleMatrix.release();
  std::vector <int> seeds;
  for (int cont = 0; cont < matrix.rows; cont++)
  {
    seeds.push_back(cont);
  }
  cv::theRNG() = cv::RNG( cv::getTickCount() );
  cv::randShuffle(seeds);

  for (int cont = 0; cont < matrix.rows; cont++)
  {
    shuffleMatrix.push_back(matrix.row(seeds[cont]));
  }
}
Example #30
0
void hulo::readMatBin(std::string filename, cv::Mat& mat) {
	std::ifstream ifs(filename, std::ios::binary);
	CV_Assert(ifs.is_open());

	int rows, cols, type;
	ifs.read((char*) (&rows), sizeof(int));
	if (rows == 0) {
		return;
	}
	ifs.read((char*) (&cols), sizeof(int));
	ifs.read((char*) (&type), sizeof(int));

	mat.release();
	mat.create(rows, cols, type);
	ifs.read((char*) (mat.data), mat.elemSize() * mat.total());
}