SimpleResourceGraph MobiExtractor::extract(const QUrl& resUri, const QUrl& fileUrl, const QString& mimeType) { Q_UNUSED( mimeType ); SimpleResource fileRes(resUri); SimpleResourceGraph graph; Mobipocket::QFileStream stream( fileUrl.toLocalFile() ); Mobipocket::Document doc(&stream); if( !doc.isValid() ) return graph; QMapIterator<Mobipocket::Document::MetaKey,QString> it(doc.metadata()); while (it.hasNext()) { it.next(); switch (it.key()) { case Mobipocket::Document::Title: fileRes.addProperty( NIE::title(), it.value() ); break; case Mobipocket::Document::Author: { SimpleResource con; con.addType( NCO::Contact() ); con.addProperty( NCO::fullname(), it.value() ); fileRes.addProperty( NCO::creator(), con ); graph << con; break; } case Mobipocket::Document::Description: { QTextDocument document; document.setHtml( it.value() ); QString plain = document.toPlainText(); if( !plain.isEmpty() ) fileRes.addProperty( NIE::comment(), plain ); break; } case Mobipocket::Document::Subject: fileRes.addProperty( NIE::subject(), it.value() ); break; case Mobipocket::Document::Copyright: fileRes.addProperty( NIE::copyright(), it.value() ); break; } } if (!doc.hasDRM()) { QString html = doc.text( maxPlainTextSize() ); QTextDocument document; document.setHtml(html); QString plainText = document.toPlainText(); if( !plainText.isEmpty() ) fileRes.addProperty( NIE::plainTextContent(), plainText ); } graph << fileRes; return graph; }
LOCAL_C void TestWorkAPIsL(CTestExecuteLogger& aLogger,CConsoleBase*& aConsole) { aConsole->Write(_L("Testing logger.Write(16BitText) \r\n")); aLogger.Write(K16BitText); aConsole->Write(_L("Testing logger.Write(8BitText) \r\n")); aLogger.Write(K8BitText); aConsole->Write(_L("Testing logger.WriteFormat(16BitText) \r\n")); TBuf<20> buf16(K16BitString); aLogger.WriteFormat(K16BitFormatText,16,&buf16); aConsole->Write(_L("Testing logger.WriteFormat(8BitText) \r\n")); TBuf8<20> buf8(K8BitString); aLogger.WriteFormat(K8BitFormatText,8,&buf8); aConsole->Write(_L("Testing logger.LogExtra() \r\n")); aLogger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16); aConsole->Write(_L("Testing logger.PrintCurrentScriptLine() \r\n")); TBuf<30> output(_L("Testing PrintCurrentScriptLine")) ; aLogger.PrintCurrentScriptLine(output) ; aConsole->Write(_L("Testing logger.LogTestCaseResult() \r\n")); TBuf<30> file(_L("TestExcuteLoggingTest.cpp")); TInt lineNo(68) ; TBuf<20> testCsNm(_L("TestCaseSomething")); aLogger.LogTestCaseResult(file, lineNo, ESevrInfo, KTEFEndTestCaseCommand, testCsNm); aConsole->Write(_L("Testing logger.LogResult() \r\n")); TBuf<30> panicStringbuf(_L("Panic string")) ; TBuf<30> fileRes(_L("TestExcuteLoggingTest.cpp")); TInt lineNum(70) ; TInt severity(RFileFlogger::ESevrHigh) ; aLogger.LogResult(EPass,panicStringbuf,lineNum,KTEFRunTestStepCommand,fileRes,RFileFlogger::ESevrHigh); }
bool Ckeyb::init(void) { isShift = false; isCtrl = false; LastKey = 0; QFile file( fn_KeyMap ); QXmlInputSource source(&file); QXmlSimpleReader reader; reader.setContentHandler( handler ); bool result = reader.parse( source ); if (result) return true; // Else load from ressource QFile fileRes(":/KEYMAP/keymap/"+fn_KeyMap); QXmlInputSource sourceRes(&fileRes); result = reader.parse(sourceRes); // if (result) qWarning("success read key ressource\n"); if (result) return true; // else load the struct for (int i = 0;i < pPC->KeyMapLenght;i++) { Keys.append(CKey(pPC->KeyMap[i].ScanCode, pPC->KeyMap[i].KeyDescription, QRect( pPC->KeyMap[i].x1, pPC->KeyMap[i].y1, RIGHT[ pPC->KeyMap[i].Type - 1 ], BOTTOM[pPC->KeyMap[i].Type - 1 ]) ) ); } return true; }
void ForestDetector::detect(std::vector<std::vector<double> >& vGroundTruth, std::vector<std::string>& vPaths, cv::Size_<int>& templateSize, std::vector<cv::Point_<int> >& vCenters) { std::ostringstream oss; oss << "../output/result_learning_" << _index << ".txt" << std::endl; std::fstream fileRes(oss.str().c_str(), std::fstream::out); for (int imageInd=0 ; imageInd < vPaths.size() ; imageInd++) { cv::Mat image = cv::imread(vPaths.at(imageInd), CV_LOAD_IMAGE_GRAYSCALE); cv::Mat integral; cv::namedWindow("lol"); cv::namedWindow("detection"); cv::namedWindow("hough"); cv::integral(image, integral); int height = image.size().height; int width = image.size().width; unsigned int patchWidth = _pForestEnv->getPatchWidth(); unsigned int patchHeight = _pForestEnv->getPatchHeight(); float currentMax=0; double pas=2; //For display cv::Mat result = cv::Mat::zeros(image.size().height/pas, image.size().width/pas, CV_32F); cv::Mat angle = cv::Mat::zeros(image.size().height/pas, image.size().width/pas, CV_64F); std::vector<cv::Point_<int> > offsetMeans; std::vector<cv::Point_<double> > offsetVar; std::vector<int> nbPatchs; cv::Mat imRoi, imIntRoi; std::vector<Leaf*> detectionVotes; std::vector<cv::Mat> detectionMeans; for (int x=0 ; x < width-patchWidth ; x+=pas)//cols { for (int y=0 ; y < height-patchHeight ; y+=pas)//rows { cv::Rect_<int> roi(x, y, patchWidth, patchHeight); cv::Rect_<int> roiInt(x, y, patchWidth+1, patchHeight+1); //patch cv::Mat meanSV; std::vector<cv::Mat> patchs; double conf=0; image(roi).copyTo(imRoi); integral(roiInt).copyTo(imIntRoi); patchs.push_back(imRoi); patchs.push_back(imIntRoi); Patch patch(patchs, roi); std::vector<Leaf*> detectedLeaf; pForest->regression(patch, detectedLeaf); double test=0; double denom=0; for (int i=0 ; i<detectedLeaf.size() ; i++) { offsetMeans.push_back(detectedLeaf[i]->getMeanOffsets()); offsetVar.push_back(detectedLeaf[i]->getVarOffsets()); nbPatchs.push_back(detectedLeaf[i]->getNumberPatchs()); meanSV = detectedLeaf[i]->getSVMean().clone(); conf = detectedLeaf[i]->getConf(); //std::cout << offsetMeans.back() << " " << offsetVar.back() << " " << nbPatchs.back() << std::endl; cv::Point_<int> offset(-offsetMeans.back().x+patchWidth/2+x, -offsetMeans.back().y+patchHeight/2+y); if (offset.x >= 0 && offset.x < width && offset.y >= 0 && offset.y < height) { offset.x = offset.x/pas; offset.y = offset.y/pas; //if ((offsetVar.back().x <= 200) && (offsetVar.back().y <= 200)) if ((conf == 1) && (detectedLeaf[i]->getTrace() < 500)) { detectionVotes.push_back(detectedLeaf[i]); detectionMeans.push_back(detectedLeaf[i]->getSVMean().clone()); detectionMeans.back().at<double>(0) = offset.x*pas; detectionMeans.back().at<double>(1) = offset.y*pas; //Might be removed => only for display (and maybe detection with particle filtering) result.at<float>(offset) += conf; denom+=conf; test+=conf*meanSV.at<double>(4); angle.at<double>(y/pas, x/pas) = test/denom; } else { //still for display angle.at<double>(y/pas, x/pas) = -100; } //display as well if (result.at<float>(offset) > currentMax) currentMax=result.at<float>(offset); } }//End of leaf loop }//End of rows loop }//End of cols loop if (detectionMeans.size()==0) { std::cout << "no detection" << std::endl; continue; } //Detection with mean shift MeanShift ms(detectionMeans); cv::Mat mean; ms.getMaxCluster(detectionMeans, mean); //For display result=result/currentMax*255; result.convertTo(result, CV_8U); angle=(angle+22)/45*255; angle.convertTo(angle, CV_8U); cv::applyColorMap(angle, angle, cv::COLORMAP_JET); cv::imshow("hough", angle); //Write in result file fileRes << vPaths[imageInd] << " ";//Image fileRes << vGroundTruth[imageInd].at(1) << " "<< vGroundTruth[imageInd].at(2) << " "<< vGroundTruth[imageInd].at(3) << " " << vGroundTruth[imageInd].at(4) << " " << vGroundTruth[imageInd].at(5) << " " << vGroundTruth[imageInd].at(6) << " ";//Ground Truth fileRes << mean.at<double>(0) << " " << mean.at<double>(1) << " " << mean.at<double>(2) << " " << mean.at<double>(3) << " " << mean.at<double>(4) << " " << mean.at<double>(5) << std::endl;//Detection //End of write cv::RotatedRect rotatedRect(cv::Point2f(mean.at<double>(0)-128/(2*pas), mean.at<double>(1)-128/(2*pas)), cv::Size2f(128/(2*pas), 128/(2*pas)), 0); //std::cout << mean.at<double>(3) << " " << mean.at<double>(4) << " " << mean.at<double>(5) << std::endl; cv::Mat imageToSave=result.clone(); cv::ellipse(imageToSave, rotatedRect, cv::Scalar_<int>(0,255,0), 2); rotatedRect.center = rotatedRect.center*pas; rotatedRect.size.height = rotatedRect.size.height*pas; rotatedRect.size.width = rotatedRect.size.width*pas; cv::ellipse(image, rotatedRect, cv::Scalar_<int>(125,255,125), 2); cv::applyColorMap(imageToSave, imageToSave, cv::COLORMAP_JET); cv::imshow("detection", image); cv::imshow("lol", imageToSave); cv::waitKey(50); }//End of images loop }