Ejemplo n.º 1
0
 void Calculate(const ProtectedRoutePlanner *route_planner,
                const PolarSettings &polar_settings,
                const TaskBehaviour &task_behaviour,
                const DerivedInfo &calculated) {
   if (route_planner != nullptr && !route_planner->IsTerrainReachEmpty())
     CalculateRoute(*route_planner);
   else
     CalculateDirect(polar_settings, task_behaviour, calculated);
 }
Ejemplo n.º 2
0
ImagePlus* CaptureManager::Access(int p, int z, bool fluorescence, bool noImage, int preload)
{
    if (p < 0 || p >= frameCount || z < 0 || z >= slideCount)
        return NULL;

    // preload next three pictures
    if (preload)
    {
        for (int i = 1; i <= 3; i++)
        {
            int newpos = i + p;
            int newZPos = z + newpos/frameCount;
            if (preload == 1) // all
            {
                if (newZPos <= slideCount)
                {
                    if (newpos >= frameCount)
                        newpos = newpos % frameCount;
                    Preload(CalculateDirect(newpos, newZPos, fluorescence));
                }
            }
            else if (preload == 2) // t-direction
            {
                if (newpos < frameCount)
                    Preload(CalculateDirect(newpos, z, fluorescence));
            }
            else // z-direction
            {
                newZPos = z + i;
                if (newZPos < slideCount)
                    Preload(CalculateDirect(p, newZPos, fluorescence));
            }
        }
    }
    int direct = CalculateDirect(p, z, fluorescence);
    ImagePlus* temp = book[direct];
    if (!temp->orig && !noImage)
        temp->orig = cvLoadImage(m_capture->getFilename(direct).mb_str());
    return temp;
}
Ejemplo n.º 3
0
void CaptureManager::Release(int p, int z, bool fluorescence)
{
    // unload previous loaded image
    if (!IsInNeighborhood(p, z))
    {

        int direct = CalculateDirect(p, z, fluorescence);
        if (book[direct]->isLoading)
            book[direct]->isLoading = false;
        else
            m_queue->AddJob(Job(Job::thread_delete, direct, book[direct]->orig), 1);
        book[direct]->orig = NULL;
    }
}
Ejemplo n.º 4
0
bool CaptureManager::SaveContours(const char* file)
{
	std::ofstream outfile;
	outfile.open(file, std::ofstream::out);
	if (!outfile)
	{
		wxLogError(_T("Unable to open file %s"), file);
		return false;
	}

	//int numContours=book[0]->contourArray.size();
	outfile << "#width: " << size.width << ", height: " << size.height << ", frameCount: " << frameCount << ", slideCount: " << slideCount << ", fluorescence: " << (hasFluorescence?"yes":"no") << ", fps: " << fps << std::endl;
	for (int frame=0; frame < frameCount; frame++)
	{
	    for (int slide=0; slide < slideCount; slide++)
        {
            for (int fluor=0; fluor < (hasFluorescence?2:1); fluor++)
            {
                int direct = CalculateDirect(frame, slide, (fluor==0?true:false));
                int numContours = book[direct]->contourArray.size();

                outfile << "#Frame: " << frame << ", Slide: " << slide << ", Fluorescence: " << (hasFluorescence&&fluor==0?"yes":"no") << ", Cell count: " << numContours << std::endl;
                for (int cell = 0; cell < numContours; cell++)
                {
                    CvSeq *seq = book[direct]->contourArray[cell];
                    int numPoints = seq->total;
                    outfile << "#Cell: " << cell+1 << ", Point Count: " << numPoints << std::endl;
                    for (int i=0; i<numPoints; i++)
                    {
                        CvPoint* point = (CvPoint*) cvGetSeqElem(seq, i);
                        outfile << point->x << " " << point->y << " ";
                    }
                    outfile << std::endl;
                }
            }
        }
	}
	outfile.flush();
	outfile.close();
	return true;
}
Ejemplo n.º 5
0
bool CaptureManager::ImportContours(const char* file)
{
	std::ifstream infile;
	//std::cout << "opening: " << file << std::endl;
	infile.open(file, std::ifstream::in);
	if (!infile)
	{
		wxLogError(_T("Unable to open file %s"), file);
		return false;
	}


	//check if there's already some detected cells.
	bool hasCells = false;
	for( int j=0; j<slideCount; j++)
	{
        for( int i=0; i<frameCount; i++ )
        {
            for( int k=0; k<2; k++ )
            {
                if (book[CalculateDirect(i,j,(k==0?false:true))]->contourArray.size())
                {
                    hasCells = true;
                    break;
                }
            }
        }
	}
	if (hasCells)
	{
		int reply = wxMessageBox(_T("There are already detected cells. Do you want to remove existing cells before importing tracking data?"), _T("Remove existing cells?"), wxYES_NO | wxCANCEL, NULL);
		if (reply == wxCANCEL)
			return false;
		else if(reply == wxYES)
		{
			for( int j=0; j<slideCount; j++)
                for( int i=0; i<frameCount; i++ )
                    for( int k=0; k<2; k++ )
                        book[CalculateDirect(i,j,(k==0?false:true))]->RemoveAllContours();
		}
	}
	//TODO: give notice if the movie info of the track-data does not match with current movie.
	int NumCells;
	int Width, Height, FrameCount, SlideCount, FPS;
	std::string ignStr, flString;
	infile >> ignStr >> Width >> ignStr >> ignStr >> Height >> ignStr >> ignStr >> FrameCount >> ignStr >> ignStr >> SlideCount >> ignStr >> ignStr >> flString >> ignStr >> FPS;
	//std::cout << Width << " " << Height << " " << FrameCount << " " << SlideCount << " " << flString << " " << FPS << std::endl;

	bool fluor = (flString.compare("yes,") == 0);

	if (Width != size.width || Height != size.height || FrameCount != frameCount || SlideCount != slideCount || fluor != hasFluorescence || FPS != fps)
	{
        int reply = wxMessageBox(_T("The contours to be loaded do not fit the current image series. Proceed?"), _T("Proceed?"), wxYES_NO | wxCANCEL, NULL);
        if (reply == wxCANCEL)
                return false;
	}
	int frame = -1, slide = -1, numContours = -1;
	bool noErrors = true;
	while (noErrors && !infile.eof())
	{
	    flString.clear();
	    infile >> ignStr >> frame >> ignStr >> ignStr >> slide >> ignStr >> ignStr >> flString >> ignStr >> ignStr >> numContours;
	    //std::cout << frame << " " << slide << " " << flString << " " << numContours << " " << std::endl;
        if (frame >= 0 && frame < frameCount && slide >= 0 && slide < slideCount && noErrors)
        {
            for (int cell=0; cell<numContours && noErrors; cell++)
            {
                int cellid,numPoints;
                /*if(cell >= 1)
                {
                    char* buffer = (char*) malloc (sizeof(char)*1);
                    fread (buffer,1,1,fp);
                    std::cout << cell << " -- " << buffer << std::endl;
                }*/
                infile >> ignStr >> cellid >> ignStr >> ignStr >> ignStr >> numPoints;
                std::vector<wxPoint> roi(numPoints);
                for (int i=0; i<numPoints && noErrors; i++)
                {
                    infile >> roi[i].x >> roi[i].y;
                    //std::cout << roi[i].x << " " << roi[i].y << std::endl;
                }

                if (noErrors)
                    book[CalculateDirect(frame, slide, (flString.compare("yes,") == 0))]->AddRoi(roi);
            }
        }
	}
	infile.close();
	this->ReloadCurrentFrameContours();
	return true;
}
Ejemplo n.º 6
0
int CaptureManager::GetTotalPos()
{
	return CalculateDirect(pos, zPos, viewFluorescence);
}