예제 #1
0
파일: Output.cpp 프로젝트: simleb/FishFlow
    Output& Output::operator<<(const Calc::Output& out)
    {
        if (_write_file)
        {
            writeToFile(out);
        }
        
        for (size_t i = 0; i < _plot_type.size(); ++i)
        {
            cv::Mat composite;
            const bool transparent = _plot_type[i] & ORIGINAL;
            
            if (transparent)
            {
                composite = out.original;
            }
            else
            {
                composite = cv::Mat::zeros(out.original.size(), CV_8UC3);
            }
            
            if (_plot_type[i] & DENSITY)
            {
                plotDensity(composite, out.density, transparent);
            }
            
            if (_plot_type[i] & (VELOCITY | USE_MASK))
            {
                plotVelocity(composite, out.velocity, out.mask);
            }
            else if (_plot_type[i] & VELOCITY)
            {
                plotVelocity(composite, out.velocity);
            }

            _video_writer[i] << composite;
        }

        ++_frame;

        return *this;
    }
void velocityCalc(std::vector<scintData>& data, const std::string& outPath)
{
	std::map<char, int> thresholdLabelToInt = {{'a', 1}, {'b',2}, {'c',3}, {'d',4}};
	std::ofstream results;
	std::string title = outPath+"EffVelocities";
	title+= ".txt";
	results.open( title.c_str() );
	for(const auto& scintillator : data)
	{	
		for(const auto& threshold : scintillator.thrData)
		{
			std::vector<double> positionsForFit;
			std::vector<double> timesForFit;	
			std::vector<double> errorsForFit;
			for(const auto& position : threshold.positions )
			{
				positionsForFit.push_back( position.positionValue );
				timesForFit.push_back( position.deltaT );
				errorsForFit.push_back( position.deltaTError);
			}
			std::pair<double,double> velocity = plotVelocity( positionsForFit, timesForFit, scintillator.ID, errorsForFit, threshold.thresholdLabel);
			int layer = 0, layerReset = 0;
			if( scintillator.ID < 49 )
			{
			  layer = 1;
			}
			else if( scintillator.ID > 48 && scintillator.ID < 97 )
			{
			  layer = 2; 
			  layerReset = 48;
			}
			else 
			{
			  layer = 3;
			  layerReset = 96;
			}
			
			results << layer << "\t" << scintillator.ID - layerReset << "\tA\t" << thresholdLabelToInt[threshold.thresholdLabel];
			results << "\t" << velocity.first << "\t" << velocity.second;
			results << "\t0\t0\t0\t0\t0\t0" << std::endl;
			results << layer << "\t" << scintillator.ID - layerReset << "\tB\t" << thresholdLabelToInt[threshold.thresholdLabel];
			results << "\t" << velocity.first << "\t" << velocity.second;
			results << "\t0\t0\t0\t0\t0\t0" << std::endl;
		}
	}

	results.close();
}