コード例 #1
0
void MdiEditor::clear()
{
	for (int i=0;i<layer_num;i++)
	{
		DeleteThread(i);
		thread_flag[i]=0;

		switch(i)
		{
		case 0:
			disconnect(show_layer[i],SIGNAL(triggered()),this,SLOT(Layer0()));
			break;
		case 1:
			connect(show_layer[i],SIGNAL(triggered()),this,SLOT(Layer1()));
			break;
		case 2:
			connect(show_layer[i],SIGNAL(triggered()),this,SLOT(Layer2()));
			break;
		case 3:
			connect(show_layer[i],SIGNAL(triggered()),this,SLOT(Layer3()));
			break;
		case 4:
			connect(show_layer[i],SIGNAL(triggered()),this,SLOT(Layer4()));
			break;
		}

		layer_view->removeAction(show_layer[i]);
		show_layer[i]->deleteLater();
		show_layer[i]=NULL;

	}

	for(int i=0;i<MAX_LAYER;i++)
	{

		parameters[i].ui_points.clear();
		parameters[i].ActIndex=-1;
		parameters[i].w_ssim=1.0f;
		parameters[i].ssim_clamp=0.0f;
		parameters[i].w_tps=0.001f;
		parameters[i].w_ui=100.0f;
		parameters[i].max_iter=2000;
		parameters[i].max_iter_drop_factor=2;
		parameters[i].eps=0.01f;
		parameters[i].start_res=8;
		parameters[i].bcond=BCOND_NONE;
		parameters[i].verbose=true;
	}
	pyramids->levels.clear();

	imageEditorL->_image_loaded=false;
	imageEditorR->_image_loaded=false;
	imageEditorM->_image_loaded=false;
	imageEditorM->_flag_error=false;
	imageEditorA->_loaded=false;
	imageEditorA->_colorfrom=1;
	ctrbar->_status=-1;

	layer_num=0;
	layer_index=0;
	mod=0;

}
コード例 #2
0
 bool MdiEditor::ReadXmlFile(QString filename)
 {
  	QDomDocument doc("settings");
  	QFile file(filename);

  	if(file.open(QIODevice::ReadOnly))
  	{
  		doc.setContent(&file);
  		QDomElement root = doc.documentElement();
  		QDomElement child1=root.firstChildElement();

   		while(!child1.isNull())
   		{
  			if (child1.tagName()=="images")
  			{
  				QString ImagePathName = pro_path+child1.attribute("image1");
  				image1=cv::imread(ImagePathName.toLatin1().data());
				parameters->fname0=(const char *)ImagePathName.toLocal8Bit();

  				ImagePathName = pro_path+child1.attribute("image2");
  				image2=cv::imread(ImagePathName.toLatin1().data());
				parameters->fname1=(const char *)ImagePathName.toLocal8Bit();
  			}
 			else if (child1.tagName()=="layers")
 			{
 				layer_num=child1.attribute("num").toInt();
 				layer_index=0;
 				QDomElement child2=child1.firstChildElement();

				for(int i=0;i<layer_num;i++)
					parameters[i].fname0=parameters[0].fname0,parameters[i].fname1=parameters[0].fname1;
 				while (!child2.isNull())
 				{
 					int index=child2.tagName().remove("l").toInt();
 					QString item;
					item.sprintf("&layer %d",index);
					show_layer[index]=new QAction(item.toLatin1().data(), this);
					layer_view->addAction(show_layer[index]);
					show_layer[index]->setCheckable(true);
					switch(index)
					{
					case 0:
						connect(show_layer[index],SIGNAL(triggered()),this,SLOT(Layer0()));
						break;
					case 1:
						connect(show_layer[index],SIGNAL(triggered()),this,SLOT(Layer1()));
						break;
					case 2:
						connect(show_layer[index],SIGNAL(triggered()),this,SLOT(Layer2()));
						break;
					case 3:
						connect(show_layer[index],SIGNAL(triggered()),this,SLOT(Layer3()));
						break;
					case 4:
						connect(show_layer[index],SIGNAL(triggered()),this,SLOT(Layer4()));
						break;
					}

 					QDomElement child3=child2.firstChildElement();
 					while(!child3.isNull())
 					{
 						if(child3.tagName()=="masks")
 						{
 							QString ImagePathName = pro_path+child3.attribute("mask1");
 							parameters[index].mask1=cv::imread(ImagePathName.toLatin1().data());

 							ImagePathName = pro_path+child3.attribute("mask2");
 							parameters[index].mask2=cv::imread(ImagePathName.toLatin1().data());
 						}
 						else if (child3.tagName()=="parameters")
 						{
 							QDomElement elem=child3.firstChildElement();
 							while(!elem.isNull())
 							{
 								if(elem.tagName()=="weight")
 								{
 									parameters[index].w_ssim=elem.attribute("ssim").toFloat();
 									parameters[index].w_tps=elem.attribute("tps").toFloat();
 									parameters[index].w_ui=elem.attribute("ui").toFloat();
 									parameters[index].ssim_clamp=1.0-elem.attribute("ssimclamp").toFloat();
 								}
 								else if(elem.tagName()=="points")
 								{
									QString points=elem.attribute("image1");
									QStringList list1=points.split(" ");
									points=elem.attribute("image2");
									QStringList list2=points.split(" ");
									for (int i=0;i<list1.count()-1;i+=2)
									{
										ConstraintPoint elem;
										elem.lp.x=list1[i].toFloat();
										elem.lp.y=list1[i+1].toFloat();
										elem.rp.x=list2[i].toFloat();
										elem.rp.y=list2[i+1].toFloat();
										parameters[index].ui_points.push_back(elem);
									}
								}
 								else if(elem.tagName()=="boundary")
								{
									int cond=elem.attribute("lock").toInt();
									switch(cond)
									{
									case 0:
										parameters[index].bcond=BCOND_NONE;
										break;
									case 1:
										parameters[index].bcond=BCOND_CORNER;
										break;
									case 2:
										parameters[index].bcond=BCOND_BORDER;
										break;
									}
								}


 								else if(elem.tagName()=="debug")
 								{
 									parameters[index].max_iter=elem.attribute("iternum").toInt();
 									parameters[index].max_iter_drop_factor=elem.attribute("dropfactor").toFloat();
 									parameters[index].eps=elem.attribute("eps").toFloat();
 									parameters[index].start_res=elem.attribute("startres").toInt();
 								}

 								elem=elem.nextSiblingElement();
 							}
 					}
 					child3=child3.nextSiblingElement();
 				}

  				child2=child2.nextSiblingElement();
  			}

  		}

   		child1=child1.nextSiblingElement();
 	}
  		file.close();
  		return true;
  }
 	return false;
 }
コード例 #3
0
Pairing * TripletThetaPhiPredictor::run(HitCollection & hits, const DetectorGeometry & geom, const GeometrySupplement & geomSupplement, const Dictionary & dict,
			int nThreads, const TripletConfigurations & layerTriplets, const Grid & grid, const Pairing & pairs){

	uint nPairs = pairs.pairing.get_count();

		LOG << "Initializing prefix sum for prediction...";
		clever::vector<uint, 1> m_prefixSum(0, nPairs+1, ctx);
		LOG << "done[" << m_prefixSum.get_count()  << "]" << std::endl;

		uint nGroups = (uint) std::max(1.0f, ceil(((float) nPairs)/nThreads));

		LOG << "Running predict kernel...";
		cl_event evt = predictCount.run(
				//detector geometry
				geom.transfer.buffer(RadiusDict()), dict.transfer.buffer(Radius()), geomSupplement.transfer.buffer(MinRadius()), geomSupplement.transfer.buffer(MaxRadius()),
				grid.transfer.buffer(Boundary()), layerTriplets.transfer.buffer(Layer3()), grid.config.nLayers,
				grid.config.MIN_Z, grid.config.sectorSizeZ(), grid.config.nSectorsZ,
				grid.config.MIN_PHI, grid.config.sectorSizePhi(), grid.config.nSectorsPhi,
				//configuration
				layerTriplets.transfer.buffer(sigmaZ()), layerTriplets.transfer.buffer(sigmaPhi()), layerTriplets.minRadiusCurvature(),
				// input
				pairs.pairing.get_mem(), nPairs,
				hits.transfer.buffer(GlobalX()), hits.transfer.buffer(GlobalY()), hits.transfer.buffer(GlobalZ()),
				hits.transfer.buffer(EventNumber()), hits.transfer.buffer(DetectorLayer()),
				hits.transfer.buffer(DetectorId()), hits.transfer.buffer(HitId()),
				// output
				m_prefixSum.get_mem(),
				//thread config
				range(nGroups * nThreads),
				range(nThreads));
		TripletThetaPhiPredictor::events.push_back(evt);
		LOG << "done" << std::endl;

		if(PROLIX){
			PLOG << "Fetching prefix sum for prediction...";
			std::vector<uint> vPrefixSum(m_prefixSum.get_count());
			transfer::download(m_prefixSum,vPrefixSum,ctx);
			PLOG << "done" << std::endl;
			PLOG << "Prefix sum: ";
			for(auto i : vPrefixSum){
				PLOG << i << " ; ";
			}
			PLOG << std::endl;
		}

		//Calculate prefix sum
		PrefixSum prefixSum(ctx);
		evt = prefixSum.run(m_prefixSum.get_mem(), m_prefixSum.get_count(), nThreads, TripletThetaPhiPredictor::events);
		uint nFoundTripletCandidates;
		transfer::downloadScalar(m_prefixSum, nFoundTripletCandidates, ctx, true, m_prefixSum.get_count()-1, 1, &evt);

		if(PROLIX){
			PLOG << "Fetching prefix sum for prediction...";
			std::vector<uint> vPrefixSum(m_prefixSum.get_count());
			transfer::download(m_prefixSum,vPrefixSum,ctx);
			PLOG << "done" << std::endl;
			PLOG << "Prefix sum: ";
			for(auto i : vPrefixSum){
				PLOG << i << " ; ";
			}
			PLOG << std::endl;
		}

		LOG << "Initializing triplet candidates...";
		Pairing * m_triplets = new Pairing(ctx, nFoundTripletCandidates, grid.config.nEvents, layerTriplets.size());
		LOG << "done[" << m_triplets->pairing.get_count()  << "]" << std::endl;

		LOG << "Running predict store kernel...";
		evt = predictStore.run(
				//geometry
				geom.transfer.buffer(RadiusDict()), dict.transfer.buffer(Radius()), geomSupplement.transfer.buffer(MinRadius()), geomSupplement.transfer.buffer(MaxRadius()),
				grid.transfer.buffer(Boundary()), layerTriplets.transfer.buffer(Layer3()), grid.config.nLayers,
				grid.config.MIN_Z, grid.config.sectorSizeZ(), grid.config.nSectorsZ,
				grid.config.MIN_PHI, grid.config.sectorSizePhi(), grid.config.nSectorsPhi,
				//configuration
				layerTriplets.transfer.buffer(sigmaZ()), layerTriplets.transfer.buffer(sigmaPhi()), layerTriplets.size(), layerTriplets.minRadiusCurvature(),
				//input
				pairs.pairing.get_mem(), pairs.pairing.get_count(),
				hits.transfer.buffer(GlobalX()), hits.transfer.buffer(GlobalY()), hits.transfer.buffer(GlobalZ()),
				hits.transfer.buffer(EventNumber()), hits.transfer.buffer(DetectorLayer()),
				hits.transfer.buffer(DetectorId()),
				//oracle
				m_prefixSum.get_mem(),
				// output
				m_triplets->pairing.get_mem(), m_triplets->pairingOffsets.get_mem(),
				//thread config
				range(nGroups * nThreads),
				range(nThreads));
		TripletThetaPhiPredictor::events.push_back(evt);
		LOG << "done" << std::endl;

		LOG << "Running filter offset monotonize kernel...";
		nGroups = (uint) std::max(1.0f, ceil(((float) m_triplets->pairingOffsets.get_count())/nThreads));
		evt = predictOffsetMonotonizeStore.run(
				m_triplets->pairingOffsets.get_mem(), m_triplets->pairingOffsets.get_count(),
				range(nGroups * nThreads),
				range(nThreads));
		TripletThetaPhiPredictor::events.push_back(evt);
		LOG << "done" << std::endl;

		if(PROLIX){
			PLOG << "Fetching triplet candidates...";
			std::vector<uint2> cands = m_triplets->getPairings();
			PLOG <<"done[" << cands.size() << "]" << std::endl;

			PLOG << "Candidates:" << std::endl;
			for(uint i = 0; i < nFoundTripletCandidates; ++i){
				PLOG << "[" << i << "] "  << cands[i].x << "-" << cands[i].y << std::endl;
			}

			PLOG << "Fetching candidates offets...";
			std::vector<uint> candOffsets = m_triplets->getPairingOffsets();
			PLOG <<"done[" << candOffsets.size() << "]" << std::endl;

			PLOG << "Candidate Offsets:" << std::endl;
			for(uint i = 0; i < candOffsets.size(); ++i){
				PLOG << "[" << i << "] "  << candOffsets[i] << std::endl;
			}
		}

		return m_triplets;
	}