float BoardDetector::detect(const cv::Mat &im)throw (cv::Exception) { _mdetector.detect(im,_vmarkers); float res; if (_camParams.isValid()) res=detect(_vmarkers,_bconf,_boardDetected,_camParams.CameraMatrix,_camParams.Distorsion,_markerSize); else res=detect(_vmarkers,_bconf,_boardDetected); return res; }
void get_libname(void){ if(detect()==CPU_LOONGSON3A) { printf("loongson3a\n"); }else if(detect()==CPU_LOONGSON3B) { printf("loongson3b\n"); }else{ #ifdef __mips64 printf("mips64\n"); #else printf("mips32\n"); #endif } }
void get_libname(void){ if(detect()==CPU_LOONGSON3A) { printf("loongson3a\n"); }else if(detect()==CPU_LOONGSON3B) { printf("loongson3b\n"); }else if(detect()==CPU_I6400) { printf("i6400\n"); }else if(detect()==CPU_P6600) { printf("p6600\n"); }else{ printf("mips64\n"); } }
void get_subarchitecture(void){ if(detect()==CPU_LOONGSON3A) { printf("LOONGSON3A"); }else if(detect()==CPU_LOONGSON3B){ printf("LOONGSON3B"); }else if(detect()==CPU_I6400){ printf("I6400"); }else if(detect()==CPU_P6600){ printf("P6600"); }else{ printf("SICORTEX"); } }
/* * Dial up on a BIZCOMP Model 1022 with either * tone dialing (mod = "V") * pulse dialing (mod = "W") */ static int biz_dialer(char *num, char *mod) { int connected = 0; char cbuf[40]; if (boolean(value(VERBOSE))) printf("\nstarting call..."); /* * Disable auto-answer and configure for tone/pulse * dialing */ if (cmd("\02K\r")) { printf("can't initialize bizcomp..."); return (0); } strcpy(cbuf, "\02.\r"); cbuf[1] = *mod; if (cmd(cbuf)) { printf("can't set dialing mode..."); return (0); } strcpy(cbuf, "\02D"); strcat(cbuf, num); strcat(cbuf, "\r"); write(FD, cbuf, strlen(cbuf)); if (!detect("7\r")) { printf("can't get dial tone..."); return (0); } if (boolean(value(VERBOSE))) printf("ringing..."); /* * The reply from the BIZCOMP should be: * 2 \r or 7 \r failure * 1 \r success */ connected = detect("1\r"); #if ACULOG if (timeout) { char line[80]; sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "biz1022", line); } #endif if (timeout) biz22_disconnect(); /* insurance */ return (connected); }
// --------------------------------------------------------------------------- // // ----------- bool bXMapCloneDetector::process(int msg, void* prm){ _bTrace_("bXMapCloneDetector::process()",true); switch(msg){ case kExtProcessCallFromIntf: return(detect(&_prm)); break; case kExtProcessCallWithParams: return(detect((clonedetector_prm*)prm)); break; default: break; } return(true); }
void get_cpuconfig(void){ if(detect()==CPU_LOONGSON3A) { printf("#define LOONGSON3A\n"); printf("#define L1_DATA_SIZE 65536\n"); printf("#define L1_DATA_LINESIZE 32\n"); printf("#define L2_SIZE 512488\n"); printf("#define L2_LINESIZE 32\n"); printf("#define DTB_DEFAULT_ENTRIES 64\n"); printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 4\n"); }else if(detect()==CPU_LOONGSON3B){ printf("#define LOONGSON3B\n"); printf("#define L1_DATA_SIZE 65536\n"); printf("#define L1_DATA_LINESIZE 32\n"); printf("#define L2_SIZE 512488\n"); printf("#define L2_LINESIZE 32\n"); printf("#define DTB_DEFAULT_ENTRIES 64\n"); printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 4\n"); }else if(detect()==CPU_I6400){ printf("#define I6400\n"); printf("#define L1_DATA_SIZE 65536\n"); printf("#define L1_DATA_LINESIZE 32\n"); printf("#define L2_SIZE 1048576\n"); printf("#define L2_LINESIZE 32\n"); printf("#define DTB_DEFAULT_ENTRIES 64\n"); printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 8\n"); }else if(detect()==CPU_P6600){ printf("#define P6600\n"); printf("#define L1_DATA_SIZE 65536\n"); printf("#define L1_DATA_LINESIZE 32\n"); printf("#define L2_SIZE 1048576\n"); printf("#define L2_LINESIZE 32\n"); printf("#define DTB_DEFAULT_ENTRIES 64\n"); printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 8\n"); }else{ printf("#define SICORTEX\n"); printf("#define L1_DATA_SIZE 32768\n"); printf("#define L1_DATA_LINESIZE 32\n"); printf("#define L2_SIZE 512488\n"); printf("#define L2_LINESIZE 32\n"); printf("#define DTB_DEFAULT_ENTRIES 32\n"); printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 8\n"); } }
bool TCompiler::detectCallDepth(TIntermNode* inputRoot, TInfoSink& inputInfoSink, bool limitCallStackDepth) { DetectCallDepth detect(inputInfoSink, limitCallStackDepth, maxCallStackDepth); inputRoot->traverse(&detect); switch (detect.detectCallDepth()) { case DetectCallDepth::kErrorNone: return true; case DetectCallDepth::kErrorMissingMain: inputInfoSink.info.prefix(EPrefixError); inputInfoSink.info << "Missing main()"; return false; case DetectCallDepth::kErrorRecursion: inputInfoSink.info.prefix(EPrefixError); inputInfoSink.info << "Function recursion detected"; return false; case DetectCallDepth::kErrorMaxDepthExceeded: inputInfoSink.info.prefix(EPrefixError); inputInfoSink.info << "Function call stack too deep"; return false; default: UNREACHABLE(); return false; } }
bool HeadSetDetect::threadLoop() { int state = detect(); //do not hold lock; Mutex::Autolock _l(mLock); if(mActive == false) { if(mFd >=0) { close(mFd); //close socket mFd = -1; } LOGD("thread to exit"); return false; } //SXLOGV("threadLoop:state=%d",state); if(state != -1) { bool on= headsetConnect(state); if(mOn != on ) { mCblk(mObserver,on); mOn = on; } } LOGD_IF(state == -1,"detect other event"); return true; }
bool has_placement( box2d<double> const& box, double margin, Keys const & keys) { return detect(keys, box, margin); }
int romloader_dpm_device_linux_uio::Open(void) { int iResult; iResult = this->uio_get_name(); if( iResult==0 ) { iResult = this->uio_probe(); if( iResult==0 ) { iResult = uio_get_addr(); if( iResult==0 ) { iResult = uio_get_size(); if( iResult==0 ) { iResult = uio_map_dpm(); if( iResult==0 ) { /* Try to identify the netX DPM. */ iResult = detect(); } } } } } return iResult; }
int main() { struct node *head = create(); detect(head); //display(head); return 0; }
int process_core_task(void) { int rtn = 0; //have_recent_added = 0; rtn = getRecentAddedFromAnyhost(config.anyhost); /* open anyhost */ if( -1 == rtn){ addInfoLog(2, "getRecentAddedFromAnyhost error(there are errors in anyhost file) and exit"); } //?õ?Ҫ?????????? rtn = getDetectOrigin(config.confFilename); /* open domain.conf */ if (-1 == rtn) { addInfoLog(2, "getDetectOrigin error(there are errors in domain.conf file) and exit"); return -1; } //rtn = checkRepeatRecordFromDomainConf(); /* 检查是否有集中探测,我这里不需要 */ //???????? rtn = detect(config.timer); if (-1 == rtn) { addInfoLog(2, "detectOrigin error and exit"); return -1; } modifyUsedTime(); copySameIPDetectRes(); addResultLog(); //write detect result rtn = write_anyhost_file(); return rtn; }
int main(int argc, char **argv) { CvCapture *capture; IplImage *frame; int key; char *filename = "usb.xml"; // Change to the name of classifier cascade = (CvHaarClassifierCascade *) cvLoad(filename, 0, 0, 0); storage = cvCreateMemStorage(0); capture = cvCaptureFromCAM(0); // Check // assert(cascade && storage && capture); cvNamedWindow("video", 1); while(1) { frame = cvQueryFrame(capture); detect(frame); key = cvWaitKey(50); } cvReleaseImage(&frame); cvReleaseCapture(&capture); cvDestroyWindow("video"); cvReleaseHaarClassifierCascade(&cascade); cvReleaseMemStorage(&storage); return 0; }
void get_subarchitecture(void){ if(detect()==CPU_LOONGSON3A) { printf("LOONGSON3A"); }else{ printf("SICORTEX"); } }
static void deferred(pony_ctx_t* ctx, detector_t* d) { d->since_deferred++; if(d->since_deferred < d->next_deferred) return; d->attempted++; bool found = false; size_t i = HASHMAP_BEGIN; view_t* view; while((view = ponyint_viewmap_next(&d->deferred, &i)) != NULL) { assert(view->deferred == true); ponyint_viewmap_removeindex(&d->deferred, i); view->deferred = false; if(!detect(ctx, d, view)) break; found = true; } if(found) { if(d->next_deferred > d->min_deferred) d->next_deferred >>= 1; } else { if(d->next_deferred < d->max_deferred)
list search_and_destroy(element e, list l) { list r = l; if (l == NULL) return NULL; if (detect(e, l) == false) return l; list tmp = l; if (IsEqual(head(l), e) == true) { l = DelFirst(l); return l; } while (llenght(l) != 1) { if (IsEqual(head(tail(l)), e) == true) { DeleteElement(l->next->value); tmp = l->next; l->next = l->next->next; free(tmp); return r; } l = tail(l); } return NULL; }
void initpcibios() { if(detect() == OK) { } }
bool compositor::enabled() { switch(detect()) { case Compositor::Metacity: return enabled_metacity(); case Compositor::Xfwm4: return enabled_xfwm4(); default: return false; } }
static PyObject * py_detect (PyObject * self, PyObject * args) { // {{{ PyObject * err = NULL; char * text; size_t inlen; int argc; DetectObj * obj; PyObject * dict; PyObject * prop; if ( ! PyArg_ParseTuple (args, "s#|O", &text, &inlen, &err) ) return NULL; argc = PyTuple_Size (args); if ( err != NULL ) { if ( ! PyList_Check (err) ) { PyErr_SetString (ErrorObject, "3th argument is must PyLis"); return NULL; } } if ( (obj = detect_obj_init ()) == NULL ) { if ( argc > 1 ) { PyObject * value = PyString_FromString ("Memory allocation failed"); PyList_Append (err, value); Py_DECREF (value); } return Py_None; } #ifdef CHARDET_BINARY_SAFE if ( detect_r (text, inlen, &obj) == CHARDET_OUT_OF_MEMORY ) #else if ( detect (text, &obj) == CHARDET_OUT_OF_MEMORY ) #endif { if ( argc > 1 ) { PyObject * value = PyString_FromString ("On handle processing, occured out of memory"); PyList_Append (err, value); Py_DECREF (value); } detect_obj_free (&obj); return Py_None; } dict = PyDict_New (); prop = Py_BuildValue ("s", obj->encoding); PyDict_SetItemString (dict, "encoding", prop); Py_DECREF (prop); prop = Py_BuildValue ("f", obj->confidence); PyDict_SetItemString (dict, "confidence", prop); Py_DECREF (prop); detect_obj_free (&obj); return dict; } // }}}
/** * Main function * checks commandline args with check_args, then calls detect() */ int main(int argc, char* argv[]) { /* Check ARGs */ if(check_args(argc, argv) != EXIT_SUCCESS) return EXIT_FAILURE; return detect(); }
//--------- Begin of function Button::wait_press ----------// // // Wait for user to press the button // // [int] timeOut - 1=enable inactive timeout // 0=disable inactive timeout // (default : 1 ) // void Button::wait_press(int timeOut) { #define INACTIVE_TIMEOUT_SECONDS 10 // 10 seconds int lastMouseX= -1, lastMouseY; DWORD timeOutTime = m.get_time()+INACTIVE_TIMEOUT_SECONDS*1000; mouse.get_event(); // clean up previous mouse events while( !detect(KEY_RETURN,KEY_ESC) && !mouse.any_click(1) ) // 1-only right mouse button { sys.yield(); mouse.get_event(); //--- when the user is inactive for a certain time, ----// //--------- close the report automatically -------------// if( timeOut ) { if( lastMouseX == mouse.cur_x && lastMouseY == mouse.cur_y ) { if( m.get_time() >= timeOutTime ) break; } else { lastMouseX = mouse.cur_x; lastMouseY = mouse.cur_y; timeOutTime = m.get_time()+INACTIVE_TIMEOUT_SECONDS*1000; } } } }
bool compositor::enable(bool status) { switch(detect()) { case Compositor::Metacity: return enable_metacity(status); case Compositor::Xfwm4: return enable_xfwm4(status); default: return false; } }
int main(int argc, char** argv) { const int width = 320, height = 240, bpp = 1; size_t numPixels = width*height*bpp; size_t numBytesRead; const char *fName = "resources/test_calib.raw"; unsigned char *cameraBuffer = new unsigned char[numPixels]; if (FILE* fp = fopen(fName, "rb")) { numBytesRead = fread(cameraBuffer, 1, numPixels, fp); fclose(fp); } else { printf("Failed to open %s\n", fName); delete cameraBuffer; return -1; } if (numBytesRead != numPixels) { printf("Failed to read %s\n", fName); delete cameraBuffer; return -1; } Tracker *tracker = (Tracker*) create(width, height, true); int num = detect(tracker, cameraBuffer); print_markers(tracker, num); destroy(tracker); delete [] cameraBuffer; return 0; }
GBL::CmRetCode_t AverageContourDetector::detect(const GBL::Image_t& inputImage, GBL::KeyPointCollection_t& detectedKeypoints, const GBL::Image_t& background, const ImageProc::ImageProc& imProc) const { GBL::Image_t outputImage = inputImage - background; // TODO: make a symmetrical one for darker blobs. This comes with a couple of additional problems... cv::threshold(outputImage, outputImage, _threshold, 255, cv::THRESH_BINARY); return detect(outputImage, detectedKeypoints); }
QAbstractCoder* QAudioManager::detect(const QByteArray &data, const QAudioManager::Mode mode) { setError(QCoder::NoError); QCoderList *coders; if(mode == QAudioManager::Available) { coders = &mAvailableCoders; } else { coders = &mSupportedCoders; } for(int i = 0; i < coders->size(); ++i) { if(coders->at(i)->detectCodec(data) != NULL) { return coders->at(i); } } if(mode == QAudioManager::Available) { if(detect(data, QAudioManager::Supported) != NULL) { setError(QCoder::UnavailableCodecError); } } else { setError(QCoder::UnsupportedCodecError); } return NULL; }
void camera_loop(boost::shared_ptr<boost::asio::io_service> io_service, cv::VideoCapture vid) { auto frame = boost::make_shared<cv::Mat>(); cv::Mat sobel, kpframe; vid >> *frame; cvtColor(*frame, sobel, cv::COLOR_BGR2GRAY); for(unsigned int n = 1; n < 7; n += 2) { cv::GaussianBlur(sobel, sobel, cv::Size(n, n), 0, 0); } cv::Sobel(sobel, sobel, CV_8U, 1, 1, 5); cv::normalize(sobel, sobel, 0, 1024, cv::NORM_MINMAX, CV_8U); for(unsigned int n = 1; n < 5; n += 2) { cv::GaussianBlur(sobel, sobel, cv::Size(n, n), 0, 0); } std::vector<cv::KeyPoint> kp; auto dt = cv::FastFeatureDetector::create(120); dt->detect(sobel, kp); cv::drawKeypoints(sobel, kp, *frame, cv::Scalar::all(1), 1); //io_service->post(std::bind(camera_process, frame)); cv::imshow("optflow", *frame); if(cv::waitKey(30) < 0) { io_service->post(std::bind(camera_loop, io_service, vid)); } }
void SiftMatcher::match() { std::vector<std::vector<cv::KeyPoint>> keypoints = detect(); std::vector<cv::Mat> descriptors = compute(keypoints); std::ofstream of(m_typeMap[m_type] + "SIFT/siftResults.txt"); for (size_t i = 1; i < descriptors.size(); ++i) { const cv::Mat& desc1 = descriptors[0]; const cv::Mat& desc2 = descriptors[i]; cv::Mat transform = readTransform(transforms[i-1]); cv::BFMatcher matcher; std::vector<cv::DMatch> matches; matcher.match(desc1, desc2, matches); double max_dist = 0; double min_dist = 100; for (int i = 0; i < desc1.rows; ++i) { double dist = matches[i].distance; if (dist < min_dist) min_dist = dist; if (dist > max_dist) max_dist = dist; } std::cout << "Max dist: " << max_dist << std::endl; std::cout << "Min dist: " << min_dist << std::endl; std::vector<cv::DMatch> goodMatches; for (size_t i = 0; i < matches.size(); ++i) { if (matches[i].distance < 2 * min_dist) goodMatches.push_back(matches[i]); } const int total = goodMatches.size(); int correct = 0; for (cv::DMatch match : goodMatches) { cv::KeyPoint p1 = keypoints[0][match.trainIdx]; cv::KeyPoint p2 = keypoints[i][match.queryIdx]; cv::Point orig = p1.pt; cv::Point rotated = p2.pt; cv::Point transformed = applyTransform(transform, orig, m_images[0]); if (std::abs(transformed.x - rotated.x) <= 5 && std::abs(transformed.y - rotated.y) <= 5) ++correct; } cv::Mat output; cv::drawMatches(m_images[0], keypoints[0], m_images[i], keypoints[i], goodMatches, output); cv::imwrite(m_typeMap[m_type] + "SIFT/" + imagePaths[0] + "->" + imagePaths[i] + ".jpg", output); of << imagePaths[0] << "->" << imagePaths[i] << ":\n" << "Total matches: " << total << '\n' << "Good matches: " << correct << '\n' << "Persentage: " << (int)ceil((double)correct / (double)total) << std::endl; } }
void blobProcess(void) { uint32_t result, i, j=0; uint32_t x, y, loseCount=0, *memory = (uint32_t *)RLS_MEMORY; int16_t bdata[8]; move(1); // get first frame (primer) result = cc_getRLSFrame(memory, RLS_MEMORY_SIZE, LUT_MEMORY, &g_numRls); while(1) { if (!g_loop) { // service calls while(g_chirpUsb->service()); handleButton(); } else { // copy if (g_numRls>QMEMSIZE) g_numRls = QMEMSIZE; for (i=0; i<g_numRls; i++) g_qmem[i] = memory[i]; // kick off next frame cc_getRLSFrame(memory, RLS_MEMORY_SIZE, LUT_MEMORY, NULL, false); // process this one cc_getMaxBlob(g_qmem, g_numRls, bdata); if (bdata[0]>0) { loseCount = 0; x = bdata[0]+(bdata[1]-bdata[0])/2; y = bdata[2]+(bdata[3]-bdata[2])/2; //servo(x, y); //printf("%d %d\n", x, y); if (detect(x, y)) { //printf("***\n"); move(0); } } else { loseCount++; if (loseCount==10) move(1); } // check for result while(!g_chirpM0->service()); // service calls while(g_chirpUsb->service()); } } }
unsigned int CurvatureDetector::detect(const LaserReading& reading, std::vector<InterestPoint*>& _point) const { Graph graph; std::vector< std::vector<Point2D> > operatorA; std::vector< std::vector<double> > signalDiff; std::vector< std::vector<unsigned int> > indexes; return detect(reading, _point, graph, operatorA, signalDiff, indexes); }