Image::Pointer
VolumeVisualizationImagePreprocessor::Process(
  Image::Pointer m_originalCT, Image::Pointer m_originalLiverMask)
{
  VVP_INFO << "Processing...";

  // converting mitk image -> itk image
  CTImage::Pointer CTImageWork = CTImage::New();
  CastToItkImage( m_originalCT, CTImageWork );

  // converting mitk image -> itk image
  BinImage::Pointer BinImageMask = BinImage::New();
  CastToItkImage( m_originalLiverMask, BinImageMask );
  
  DetermineBoundingBox( BinImageMask );
  
  if( m_MaxX < m_MinX
   || m_MaxY < m_MinY
   || m_MaxZ < m_MinZ )
    return 0;
  
  CTImageWork = Gaussian(Crop( CTImageWork ));
  BinImageMask = Crop( BinImageMask );

  CTImage::Pointer itkResult =Composite(CTImageWork,BinImageMask,Dilate(BinImageMask),Erode(BinImageMask));

  mitk::Image::Pointer mitkResult= mitk::Image::New();
               mitk::CastToMitkImage( itkResult, mitkResult ); //TODO here we can perhaps save memory

  VVP_INFO << "Finished...";

  return mitkResult;
}
Пример #2
0
void CGraphicsComponent::NativeBlitAndroid(int32_t x, int32_t y, int32_t aWidth, int32_t aHeight,
    int32_t cropLeft, int32_t cropTop, int32_t cropRight, int32_t cropBottom, int32_t orgWidth, int32_t orgHeight)
{
   const bool bCrop = (cropLeft != 0) || (cropTop != 0) || (cropRight != orgWidth) || (cropBottom != orgHeight);
   if (bCrop) {
      Crop(cropLeft, cropTop, cropRight, cropBottom);
   }
   glDrawTexiOES(x, y, 0, aWidth, aHeight);
   if (glGetError() != 0) LOG_ERROR("Error!");
   if (bCrop) {
      Crop(0, 0, orgWidth, orgHeight);
   }
}
Пример #3
0
void FaceCrop::CropAllGrayLevelFace(vector<FaceInfo> *cropFaceSet){

	//for(vector<FP>::iterator iter=fpSet.begin() ; iter!=fpSet.end() ; iter++ ){
	//	Crop(iter->lefteye,iter->righteye,iter->nose,iter->mouth);
	//	saveCropImage();
	//}	
	FaceInfo temp;
	for(int i=0 ; i<fpSet.size() ; i++ ){
		if(Crop(fpSet[i].lefteye,fpSet[i].righteye,fpSet[i].nose,fpSet[i].mouth)==true){
			IplImage* grayImg=cvCreateImage(cvSize(normalizeImg->width,normalizeImg->height),IPL_DEPTH_8U,1);
			cvCvtColor(normalizeImg,grayImg,CV_BGR2GRAY);
			cvReleaseImage(&normalizeImg);
			temp.face=grayImg;
			temp.leftdown=leftdown;
			temp.leftTop=leftTop;
			temp.rightdown=rightdown;
			temp.rightTop=rightTop;
			cropFaceSet->push_back(temp);
		}
	}	
	//for(vector<IplImage*>::iterator iter=cropFaceSet.begin(); iter!=cropFaceSet.end()  ;iter++){
	//	cvNamedWindow("Img",1);
	//	cvShowImage("Img",*iter);
	//	cvWaitKey(0);
	//}

}
Пример #4
0
void check_world_resources(World_map* world)
{
  if (!world) {
    return;
  }
  int land = world->land_count();
  int size = world->get_size() * world->get_size();
  float land_percent = float((100.0 * float(land)) / size);
  debugmsg("Land tiles: %d/%d (%f percent)", land, size, land_percent);
  for (int i = 0; i < CROP_MAX; i++) {
    Crop crop = Crop(i);
    int crop_count = world->crop_count(crop);
    float crop_percent = float((100.0 * float(crop_count)) / size);
    float crop_land_percent = float((100.0 * float(crop_count)) / land);
    debugmsg("%s: %d/%d/%d (%f/%f percent, should be %d)",
             Crop_data[crop]->name.c_str(), crop_count, land, size,
             crop_land_percent, crop_percent, Crop_data[crop]->percentage);
  }
  for (int i = 0; i < MINERAL_MAX; i++) {
    Mineral mineral = Mineral(i);
    int mineral_count = world->mineral_count(mineral);
    float mineral_percent = float((100.0 * float(mineral_count)) / size);
    float mineral_land_percent = float((100.0 * float(mineral_count)) / land);
    debugmsg("%s: %d/%d/%d (%f/%f percent, should be %d)",
             Mineral_data[mineral]->name.c_str(), mineral_count, land, size,
             mineral_land_percent, mineral_percent,
             Mineral_data[mineral]->percentage);
  }
}
Пример #5
0
PolynomialMod2 PolynomialMod2::AllOnes(unsigned int bitLength)
{
	PolynomialMod2 result((word)0, bitLength);
	SetWords(result.reg, ~(word)0, result.reg.size());
	if (bitLength%WORD_BITS)
		result.reg[result.reg.size()-1] = (word)Crop(result.reg[result.reg.size()-1], bitLength%WORD_BITS);
	return result;
}
Пример #6
0
void PolynomialMod2::Randomize(RandomNumberGenerator &rng, size_t nbits)
{
	const size_t nbytes = nbits/8 + 1;
	SecByteBlock buf(nbytes);
	rng.GenerateBlock(buf, nbytes);
	buf[0] = (byte)Crop(buf[0], nbits % 8);
	Decode(buf, nbytes);
}
Пример #7
0
PolynomialMod2 PolynomialMod2::AllOnes(size_t bitLength)
{
	PolynomialMod2 result((word)0, bitLength);
	SetWords(result.reg, word(SIZE_MAX), result.reg.size());
	if (bitLength%WORD_BITS)
		result.reg[result.reg.size()-1] = (word)Crop(result.reg[result.reg.size()-1], bitLength%WORD_BITS);
	return result;
}
DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative(
	HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
	byte *representative, size_t representativeBitLength,
	byte *recoverableMessage) const
{
	assert(representativeBitLength >= MinRepresentativeBitLength(hashIdentifier.second, hash.DigestSize()));

	const size_t u = hashIdentifier.second + 1;
	const size_t representativeByteLength = BitsToBytes(representativeBitLength);
	const size_t digestSize = hash.DigestSize();
	const size_t saltSize = SaltLen(digestSize);
	const byte *const h = representative + representativeByteLength - u - digestSize;

	SecByteBlock digest(digestSize);
	hash.Final(digest);

	DecodingResult result(0);
	bool &valid = result.isValidCoding;
	size_t &recoverableMessageLength = result.messageLength;

	valid = (representative[representativeByteLength - 1] == (hashIdentifier.second ? 0xcc : 0xbc)) && valid;
	valid = VerifyBufsEqual(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second) && valid;

	GetMGF().GenerateAndMask(hash, representative, representativeByteLength - u - digestSize, h, digestSize);
	if (representativeBitLength % 8 != 0)
		representative[0] = (byte)Crop(representative[0], representativeBitLength % 8);

	// extract salt and recoverableMessage from DB = 00 ... || 01 || M || salt
	byte *salt = representative + representativeByteLength - u - digestSize - saltSize;
	byte *M = std::find_if(representative, salt-1, std::bind2nd(std::not_equal_to<byte>(), 0));
	recoverableMessageLength = salt-M-1;
	if (*M == 0x01 
		&& (size_t)(M - representative - (representativeBitLength % 8 != 0)) >= MinPadLen(digestSize)
		&& recoverableMessageLength <= MaxRecoverableLength(representativeBitLength, hashIdentifier.second, digestSize))
	{
		memcpy(recoverableMessage, M+1, recoverableMessageLength);
	}
	else
	{
		recoverableMessageLength = 0;
		valid = false;
	}

	// verify H = hash of M'
	byte c[8];
	PutWord(false, BIG_ENDIAN_ORDER, c, (word32)SafeRightShift<29>(recoverableMessageLength));
	PutWord(false, BIG_ENDIAN_ORDER, c+4, word32(recoverableMessageLength << 3));
	hash.Update(c, 8);
	hash.Update(recoverableMessage, recoverableMessageLength);
	hash.Update(digest, digestSize);
	hash.Update(salt, saltSize);
	valid = hash.Verify(h) && valid;

	if (!AllowRecovery() && valid && recoverableMessageLength != 0)
		{throw NotImplemented("PSSR_MEM: message recovery disabled");}
	
	return result;
}
Пример #9
0
cv::Mat Barcode_Locator::DrawBarLoc(cv::Mat img_input){
    img_input.copyTo(this->img);

    cv::Mat grad_x , grad_y;
    cv::Mat abs_grad_x , abs_grad_y;

    int scale = 1;
    int delta = 0;
    int ddepth = CV_16S;

//---------------------------------Gradient Calculation------------------------------------
    cv::cvtColor(this->img,this->img_gray,CV_BGR2GRAY);
    cv::GaussianBlur( this->img_gray, this->img_gray, cv::Size(3,3), 0, 0, cv::BORDER_DEFAULT );

#pragma omp parallel sections
{
    #pragma omp section
    {
            /// Gradient X
            cv::Sobel( this->img_gray, grad_x, ddepth, 1, 0, 3, scale, delta, cv::BORDER_DEFAULT );
            cv::convertScaleAbs(grad_x , abs_grad_x);
    }
    #pragma omp section

    {
            /// Gradient Y
            cv::Sobel( this->img_gray, grad_y, ddepth, 0, 1, 3, scale, delta, cv::BORDER_DEFAULT );
            cv::convertScaleAbs(grad_y , abs_grad_y);
    }
}
//--------------------------------Gradient difference between x and y-------------------
    cv::Mat grad_diff;
    grad_diff = cv::abs(abs_grad_x) - cv::abs(abs_grad_y);
    //region normalization
    cv::blur(grad_diff,this->img_smooth,cv::Size(31,31),cv::Point(-1,-1));
    //find the location of the max value
    double minval, maxval;
    cv::Point minloc, maxloc;
    cv::minMaxLoc(this->img_smooth, &minval, &maxval, &minloc, &maxloc);


    cv::Mat Result;

    if(maxval > 130.0){
        // thresholding by OTSU method
        cv::Mat thres;
        cv::threshold(this->img_smooth,thres,0,255,CV_THRESH_BINARY | CV_THRESH_OTSU);

        cv::Point MaxPoint;
        MaxPoint.x = maxloc.x;
        MaxPoint.y = maxloc.y;
        cv::Rect A = Crop( thres ,  MaxPoint );

        this->img.copyTo(Result);
        cv::rectangle(Result , A , cv::Scalar(255,0,0) );
    }
    return Result;
}
Пример #10
0
void FaceCrop::CropAllFace(){

	//for(vector<FP>::iterator iter=fpSet.begin() ; iter!=fpSet.end() ; iter++ ){
	//	Crop(iter->lefteye,iter->righteye,iter->nose,iter->mouth);
	//	saveCropImage();
	//}	
	for(int i=0 ; i<fpSet.size() ; i++ ){
		if(Crop(fpSet[i].lefteye,fpSet[i].righteye,fpSet[i].nose,fpSet[i].mouth)==true){
			saveCropImage(i);
		}
	}	
}
Пример #11
0
void FaceCrop::CropAllFace(vector<IplImage*> *cropFaceSet){


	
	for(int i=0 ; i<fpSet.size() ; i++ ){
		if(Crop(fpSet[i].lefteye,fpSet[i].righteye,fpSet[i].nose,fpSet[i].mouth)==true){
			cropFaceSet->push_back(normalizeImg);
		}
	}	


}
Пример #12
0
void GenerateRLE16::CreateFromImage(const Image* image, bool dither)
	{
	int minX=0;
	int minY=0;
	int maxX=0;
	int maxY=0;

	// Crop image
	Crop(image,&minX,&minY,&maxX,&maxY);
	if (maxX<minX || maxY<minY)
		{
		return;
		}

	hPitch_=(unsigned short)(maxX-minX+1);
	vPitch_=(unsigned short)(maxY-minY+1);

	hOffset_=(unsigned short)minX;
	vOffset_=(unsigned short)minY;

	// First, create 16-bit version
	unsigned short* data=0;
	unsigned char* mask=0;
	Palettize(image,&data,&mask,dither);

	// Create RLE data
	opaqueSize_=GetRLESize(data,mask);
	if (opaqueSize_>0)
		{
		opaqueData_=static_cast<unsigned char*>(Malloc(opaqueSize_));
		CreateRLE(data,mask,opaqueData_);
		}

	// Create RLE mask
	alphaSize_=GetRLESize_Alpha(data,mask);
	if (alphaSize_>0)
		{
		alphaData_=static_cast<unsigned char*>(Malloc(alphaSize_));
		CreateRLE_Alpha(data,mask,alphaData_);
		}


	// Release temp stuff
	if (data)
		{
		Free(data);
		}
	if (mask)
		{
		Free(mask);
		}
	}
Пример #13
0
void FaceCrop::CropAllGrayLevelFace(vector<IplImage*> *cropFaceSet){

	
	for(int i=0 ; i<fpSet.size() ; i++ ){
		if(Crop(fpSet[i].lefteye,fpSet[i].righteye,fpSet[i].nose,fpSet[i].mouth)==true){
			IplImage* grayImg=cvCreateImage(cvSize(normalizeImg->width,normalizeImg->height),IPL_DEPTH_8U,1);
			cvCvtColor(normalizeImg,grayImg,CV_BGR2GRAY);
			cropFaceSet->push_back(grayImg);
			cvReleaseImage(&normalizeImg);

		}
	}	


}
Пример #14
0
word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max)
{
	const word32 range = max-min;
	const unsigned int maxBits = BitPrecision(range);

	word32 value;

	do
	{
		GenerateBlock((byte *)&value, sizeof(value));
		value = Crop(value, maxBits);
	} while (value > range);

	return value+min;
}
Пример #15
0
word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max)
{
	word32 range = max-min;
	const int maxBytes = BytePrecision(range);
	const int maxBits = BitPrecision(range);

	word32 value;

	do
	{
		value = 0;
		for (int i=0; i<maxBytes; i++)
			value = (value << 8) | GenerateByte();

		value = Crop(value, maxBits);
	} while (value > range);

	return value+min;
}
Пример #16
0
void InterpolateImage(Image& img, const Rect& _rc)
{
    Rect rc = _rc & img.GetSize();
    Image m = Crop(img, rc);
    TimeStop tm;
    Image imp = CreateImage(rc.GetSize(), Null);
    Over(imp, Point(0, 0), m, m.GetSize());
    Progress pi("Interpolating...");
    for(int qq = 0; qq < 2000; qq++) {
        InterpolateFilter f;
        f.todo = 0;
        imp = Filter(imp, f);
        Over(imp, Point(0, 0), m, m.GetSize());
        if(f.todo == 0)
            break;
        if(pi.SetCanceled(qq, 2000))
            break;
    }
    Copy(img, rc.TopLeft(), imp, imp.GetSize());
}
Пример #17
0
BTRESULT BTCImageDataEx::RotateEx(double dAngle, const enum BTDirection& Direction /* = Right */, BTCOLORREF colBackground /* = 0x00000000 */, bool bCrop /* = true */)
{
	if(!m_pBitmapInfo)
		return BT_E_POINTER;

	long lOldWidth  = GetWidth();
	long lOldHeight = GetHeight();

	if( false == Rotate( dAngle, Direction, colBackground))
		return BT_S_FALSE;

	if( true == bCrop)
	{
		long x = (GetWidth() / 2) - (lOldWidth / 2);
		long y = (GetHeight() / 2) - (lOldHeight / 2);

		return Crop( x, y, lOldWidth, lOldHeight) ? BT_S_OK : BT_S_FALSE;
	}

	return BT_S_OK;
}
void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng, 
	const byte *recoverableMessage, size_t recoverableMessageLength,
	HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
	byte *representative, size_t representativeBitLength) const
{
	assert(representativeBitLength >= MinRepresentativeBitLength(hashIdentifier.second, hash.DigestSize()));

	const size_t u = hashIdentifier.second + 1;
	const size_t representativeByteLength = BitsToBytes(representativeBitLength);
	const size_t digestSize = hash.DigestSize();
	const size_t saltSize = SaltLen(digestSize);
	byte *const h = representative + representativeByteLength - u - digestSize;

	SecByteBlock digest(digestSize), salt(saltSize);
	hash.Final(digest);
	rng.GenerateBlock(salt, saltSize);

	// compute H = hash of M'
	byte c[8];
	PutWord(false, BIG_ENDIAN_ORDER, c, (word32)SafeRightShift<29>(recoverableMessageLength));
	PutWord(false, BIG_ENDIAN_ORDER, c+4, word32(recoverableMessageLength << 3));
	hash.Update(c, 8);
	hash.Update(recoverableMessage, recoverableMessageLength);
	hash.Update(digest, digestSize);
	hash.Update(salt, saltSize);
	hash.Final(h);

	// compute representative
	GetMGF().GenerateAndMask(hash, representative, representativeByteLength - u - digestSize, h, digestSize, false);
	byte *xorStart = representative + representativeByteLength - u - digestSize - salt.size() - recoverableMessageLength - 1;
	xorStart[0] ^= 1;
	xorbuf(xorStart + 1, recoverableMessage, recoverableMessageLength);
	xorbuf(xorStart + 1 + recoverableMessageLength, salt, salt.size());
	memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second);
	representative[representativeByteLength - 1] = hashIdentifier.second ? 0xcc : 0xbc;
	if (representativeBitLength % 8 != 0)
		representative[0] = (byte)Crop(representative[0], representativeBitLength % 8);
}
Пример #19
0
void FaceCrop::CropAllFace(vector<FaceInfo> *cropFaceSet){

	//for(vector<FP>::iterator iter=fpSet.begin() ; iter!=fpSet.end() ; iter++ ){
	//	Crop(iter->lefteye,iter->righteye,iter->nose,iter->mouth);
	//	saveCropImage();
	//}	
	FaceInfo temp;
	for(int i=0 ; i<fpSet.size() ; i++ ){
		if(Crop(fpSet[i].lefteye,fpSet[i].righteye,fpSet[i].nose,fpSet[i].mouth)==true){
			temp.face=normalizeImg;
			temp.leftdown=leftdown;
			temp.leftTop=leftTop;
			temp.rightdown=rightdown;
			temp.rightTop=rightTop;
			cropFaceSet->push_back(temp);
		}
	}	
	//for(vector<IplImage*>::iterator iter=cropFaceSet.begin(); iter!=cropFaceSet.end()  ;iter++){
	//	cvNamedWindow("Img",1);
	//	cvShowImage("Img",*iter);
	//	cvWaitKey(0);
	//}

}
Пример #20
0
	BinaryVector *BinaryVector::CropVector(int start, int count = -1) {
		int endIndex = count == -1 ? GetRowCount() - 1 : (start + count - 1);
		BinaryMatrix *croped = Crop(0, 0, start, endIndex);
	};
Пример #21
0
cv::Mat Barcode_Locator::GetBarLoc(cv::Mat img_input){
    this->img = img_input;

    cv::Mat grad_x , grad_y;
    cv::Mat abs_grad_x , abs_grad_y;

    int scale = 1;
    int delta = 0;
    int ddepth = CV_16S;

//---------------------------------Gradient Calculation------------------------------------
    cv::cvtColor(this->img,this->img_gray,CV_BGR2GRAY);
    cv::GaussianBlur( this->img_gray, this->img_gray, cv::Size(3,3), 0, 0, cv::BORDER_DEFAULT );
#pragma omp parallel sections
{
    #pragma omp section
    {
            /// Gradient X
            cv::Sobel( this->img_gray, grad_x, ddepth, 1, 0, 3, scale, delta, cv::BORDER_DEFAULT );
            cv::convertScaleAbs(grad_x , abs_grad_x);
    }
    #pragma omp section

    {
            /// Gradient Y
            cv::Sobel( this->img_gray, grad_y, ddepth, 0, 1, 3, scale, delta, cv::BORDER_DEFAULT );
            cv::convertScaleAbs(grad_y , abs_grad_y);
    }
}
    //cv::imshow("grad_x",grad_x);
    //cv::imshow("grad_y",grad_y);
    //cv::imshow("abs_x",abs_grad_x);
    //cv::imshow("abs_y",abs_grad_y);

//--------------------------------Gradient difference between x and y-------------------
    cv::Mat grad_diff;
    grad_diff = cv::abs(abs_grad_x) - cv::abs(abs_grad_y);

    //cv::imshow("diff",grad_diff);    

    cv::blur(grad_diff,this->img_smooth,cv::Size(31,31),cv::Point(-1,-1));//region normalization
    //cv::imshow("smooth",this->img_smooth);

    //find the location of the max value
    double minval, maxval;
    cv::Point minloc, maxloc;
    cv::minMaxLoc(this->img_smooth, &minval, &maxval, &minloc, &maxloc);

    //cout << "Max value : " << maxval << endl;

    //cv::Mat Result1;
    cv::Mat Result;

    if(maxval > 130.0 && maxloc.x > 0 && maxloc.y > 0){
        // thresholding by OTSU method
        cv::Mat thres;
        cv::threshold(this->img_smooth,thres,0,255,CV_THRESH_BINARY | CV_THRESH_OTSU);
        //cv::imshow("thres",thres);




        cv::Point MaxPoint;
        MaxPoint.x = maxloc.x;
        MaxPoint.y = maxloc.y;
        cv::Rect A = Crop( thres ,  MaxPoint );

        if(A.width >= 0 && A.height >= 0){

            emit sendBarcodeLocation(A);
            emit sendIsBarcodeLocated(true);

            //cv::rectangle(this->img , A , cv::Scalar(255,0,0) );
            //cv::imshow("REs",this->img);
            Result = this->img_gray(A);

            //cv::Mat Result;
            cv::resize(Result,Result,cv::Size(1.2*Result.cols,1.2*Result.rows));
            //cv::imshow("big",Result);

        }

    }else{
        emit sendIsBarcodeLocated(false);
    }

    return Result;
}
Пример #22
0
bool Building::load_data(std::istream& data)
{
  int tmptype;
  data >> tmptype;
  if (tmptype <= 0 || tmptype >= BUILD_MAX) {
    debugmsg("Building loaded type of %d (range is 1 to %d).",
             tmptype, BUILD_MAX - 1);
    return false;
  }
  type = Building_type(tmptype);

  data >> open >> pos.x >> pos.y >> construction_left >> workers;

  crops_grown.clear();
  data >> field_output;
  int num_crops;
  data >> num_crops;
  for (int i = 0; i < num_crops; i++) {
    int tmpcrop, crop_amt;
    data >> tmpcrop >> crop_amt;
    if (tmpcrop <= 0 || tmpcrop >= CROP_MAX) {
      debugmsg("Building loaded crop %d/%d; type %d (range is 1 to %d).",
               i, num_crops, tmpcrop, CROP_MAX - 1);
      return false;
    }
    crops_grown.push_back( Crop_amount( Crop(tmpcrop), crop_amt ) );
  }

  minerals_mined.clear();
  data >> shaft_output;
  int num_mins;
  data >> num_mins;
  for (int i = 0; i < num_mins; i++) {
    int tmpmin, min_amt;
    data >> tmpmin >> min_amt;
    if (tmpmin <= 0 || tmpmin >= MINERAL_MAX) {
      debugmsg("Building loaded mineral %d/%d; type %d (range is 1 to %d).",
               i, num_mins, tmpmin, MINERAL_MAX - 1);
      return false;
    }
    minerals_mined.push_back( Mineral_amount( Mineral(tmpmin), min_amt ) );
  }

  data >> hunter_level;
  int tmptarget, tmpaction;
  data >> tmptarget >> tmpaction;
  if (tmptarget >= ANIMAL_MAX) {
    debugmsg("Building loaded hunting target %d (range is 1 to %d).",
             tmptarget, ANIMAL_MAX - 1);
    return false;
  }
  hunting_target = Animal(tmptarget);
  if (tmpaction >= ANIMAL_ACT_MAX) {
    debugmsg("Building loaded hunting action %d (range is 1 to %d).",
             tmpaction, ANIMAL_ACT_MAX - 1);
    return false;
  }
  hunting_action = Animal_action(tmpaction);

  int queue_size;
  data >> queue_size;
  for (int i = 0; i < queue_size; i++) {
    Recipe tmp_recipe;
    if (!tmp_recipe.load_data(data)) {
      debugmsg("Building failed to load recipe %d/%d.", i, queue_size);
      return false;
    }
    int recipe_amt;
    data >> recipe_amt;
    build_queue.push_back( Recipe_amount( tmp_recipe, recipe_amt ) );
  }

  return true;
}