void Frame::setImage(Mat _image) { Size newImageSize(_image.cols, _image.rows); if (maskSize != Size(-1, -1) && maskSize != newImageSize) { stringstream ss; ss << "Image with size [" << newImageSize.width << "][" << newImageSize.height << "] can not be loaded because mask with different size [" << maskSize.width << "][" << maskSize.height << "] was loaded"; throw logic_error(ss.str()); } image.release(); image = _image.clone(); imageSize = newImageSize; }
CodeBookModel::CodeBookModel( const IplImage** images, uint imageCount, double colorThreshold, uint maxNegativeRunLengthThreshold, double alpha, double beta ) { this->colorThreshold = colorThreshold; this->alpha = alpha; this->beta = beta; for( uint i = 0; i < imageCount; ++i ) { const IplImage* image = images[ i ]; CvSize newImageSize( cvGetSize( image ) ); if( i == 0 ) { imageSize = newImageSize; uint codeBookCount = imageSize.width * imageSize.height; codeBooks = new CodeWord*[ codeBookCount ]; memset( codeBooks, 0, sizeof( CodeWord* ) * codeBookCount ); } } finishTraining( maxNegativeRunLengthThreshold ); frameCount = 0; }