void InputDialogue::okClicked(){ if(what == "port"){ bool parsed = false; //try parse port try{ parsed = testInput(1024,65000); }catch(ErrorClass ec){ showErrorMessage(ec.message, "error"); return; } if(!parsed){ QString message = "Incorrect input for port. Port must be between 1200 and 65000"; showErrorMessage(message, "error"); return; } QSettings setting("settings.ini",QSettings::IniFormat); //grouping the settings setting.beginGroup("Connection"); setting.setValue("port", ui->lineEdit->text().toInt()); setting.endGroup(); management->setPort(ui->lineEdit->text().toInt()); this->close(); } }
HogSvmExSClassifier::HogSvmExSClassifier() :exSearch(*(new ExhaustiveSearch)) { svm=new cv::SVM; descriptor=new HOGDescriptor; descriptor->winSize=cv::Size(160,96); exSearch.setRatio(double(160)/96); exSearch.setStride(0.5); exSearch.setScales(QVector<double>({1,0.9})); auto detectionF = [&](Mat img)->bool{ resize(img,img,Size(160,96)); std::vector<float> descriptorValue; descriptor->compute(img,descriptorValue); int inCols=descriptorValue.size(); cv::Mat testInput(1,inCols,CV_32FC1); for(int i=0;i<inCols;i++){ testInput.at<float>(0,i)=descriptorValue[i]; } float fRes=svm->predict(testInput); if(fRes > 0.1){ return true; }else{ return false; } }; exSearch.setDetectionFunction(detectionF); }
void Player::testTimer() { int t = clock(); if ( (t - sdata_.tstart_) > sparams_.timeLimitMS_ ) pleaseStop(); testInput(); }
__interrupt void USCI0RX_ISR(void) { volatile char inChar; inChar = UCA0RXBUF; // Read in UART serial port testInput(inChar); // Test the input }//UART_ISR()
bool Player::checkForStop() { if ( sdata_.totalNodes_ && !(sdata_.totalNodes_ & TIMING_FLAG) ) { if ( sparams_.timeLimitMS_ > 0 ) testTimer(); else testInput(); } return stop_; }
int main(int argc, char** argv){ struct timespec t0, t1; clock_gettime(CLOCK_MONOTONIC_RAW, &t0); if(!testInput(argc, argv)) return -1; printf("Valor buscado: \t%i\nQtd de threads: 0\n", gX); int i = funcao(); clock_gettime(CLOCK_MONOTONIC_RAW, &t1); printf("Tempo de execução:\t%lf seg.\n", difTime(t0, t1)); return 0; }
void Game::update(sf::Time dt) { switch(state) { case State::MENU: break; case State::CHARGEMENT: loading.update(dt); break; case State::JEU : if(!chat.isActive()) { testInput(); } else { playerInput.MoveUp = playerInput.MoveDown = playerInput.MoveLeft = playerInput.MoveRight = playerInput.aAttack = playerInput.eAttack = false; } if(pingTimer.asSeconds() >= 1) { sf::Packet packet; packet << NetworkValues::PING << ++pingId; informationSocket.send(packet); pingTimer -= sf::seconds(1.f); } else { pingTimer += dt; } pingCounter += dt; sendInput(); receivePacket(); receiveInformationPacket(); world.update(dt); chat.update(); break; } if(timeOutTimer >= timeOut) { std::cout << "Connection timed out" << std::endl; running = false; } }
bool TreeHogClassifier::predict(cv::Mat img) { qDebug() << "Klasyfikacja"; std::vector<float> descriptorValue; descriptor->compute(img,descriptorValue); qDebug() << "Deskryptor ok"; int inCols=descriptorValue.size(); cv::Mat testInput(1,inCols,CV_32FC1); for(int i=0;i<inCols;i++){ testInput.at<float>(0,i)=descriptorValue[i]; } qDebug() << "Trees"; float fRes=trees->predict(testInput); qDebug() << "Klasa: " << fRes; if(fRes > 0.1){ return true; }else{ return false; } }
int main(int argc, char** argv){ if(!testInput(argc, argv)) return -1; int i; pthread_t tProducer; pthread_t tConsumer[gQtde]; // Lista de threads com tamanho variável // Inicialização dos semáforos sem_init(&full, 0, 0); sem_init(&empty, 0, N); sem_init(&mutex, 0, 1); // Inicialização do buffer com 0 for(i=0; i<N; i++) gBuffer[i] = 0; printf("----- Iniciando produção de %i números e %i consumidores.\n", Q, gQtde); // Criação das Threads - Produtoras e Consumidoras pthread_create(&tProducer, NULL, threadProducer, NULL); for(i=0; i<gQtde; i++) // Criação de todas as threads consumidoras pthread_create(&tConsumer[i], NULL, threadConsumer, NULL); // Retirados os joins pois está sendo utilizado o pthread_exit e exit pthread_join(tProducer, NULL); for(i=0; i<gQtde; i++) pthread_join(tConsumer[i], NULL); // sem_destroy(&full); // sem_destroy(&empty); // sem_destroy(&mutex); return 0; }
void CConvertToRfc1123FormTest::DoTestsL() { TInt ii; for (ii=0; ii< KInvalidTimeNumTests; ++ii) { TInternetDate date; TRAPD( error, date.SetDateL(KInvalidTimeTestCases[ii])); if (error && error != KErrCorrupt) { User::LeaveIfError(error); } } for (ii=0; ii < KNumberDEF126191TestCases; ++ii) { TInternetDate internetDate; _LIT(KTest, "Test for fix DEF126191 - Case: "); TInternetDateOffsetTestCase tc = KDEF126191TestCases[ii]; TBuf<512> testName; testName.Append(KTest); TPtrC8 testDate( tc.iTextInput ); TBuf<150> bufTestDate; bufTestDate.Copy(testDate); testName.Append(bufTestDate); _LIT(KTestExpected, "\n \t \t \t \t And Expected Result is: "); testName.Append(KTestExpected); TPtrC8 expectedTestDate( tc.iExpectedOutput ); TBuf<150> bufExpectedTestDate; bufExpectedTestDate.Copy(expectedTestDate); testName.Append(bufExpectedTestDate); iTestHarness->StartTestL(testName); TInt err = 0; internetDate.SetDateL(tc.iTextInput); TDateTime parsedDate = internetDate.DateTime(); TInternetDate ConvertparsedDate(parsedDate); HBufC8* textDate = ConvertparsedDate.InternetDateTimeL(TInternetDate::ERfc1123Format); CleanupStack::PushL(textDate); TBuf8 <50> KExpcted; KExpcted.Copy(tc.iExpectedOutput); if(textDate->CompareF(KExpcted) != 0) { err = KErrBadDescriptor; } CleanupStack::PopAndDestroy(textDate); iTestHarness->EndTest(err); } for (ii=0; ii< KNumberRfc1123GMTTzTestCases; ++ii) { TInternetDateTestCase tc = KRfc1123GMTTzTestCases[ii]; TDateTime time(tc.iYear, tc.iMonth, tc.iDay, tc.iHour, tc.iMin, tc.iSecond, 0); TPtrC8 expected(tc.iTextFormat); ConvertTestL(time, expected); } for (ii=0; ii< KNumberINC090613TestCases; ++ii) { TInternetDate date; _LIT(KTest, "Test for fix INC090613 - Case: "); TBuf<256> testname; testname.Append(KTest); TPtrC8 testdate(KINC090613TestCases[ii]); TBuf<150> buftestdate; buftestdate.Copy(testdate); testname.Append(buftestdate); iTestHarness->StartTestL(testname); TRAPD(err,date.SetDateL(KINC090613TestCases[ii])); iTestHarness->EndTest(err); User::LeaveIfError(err); } for (ii=0; ii< KNumberINC107382TestCases; ++ii) { TInternetDate date; _LIT(KTest, "Test for fix INC107382 - Case: "); TBuf<256> testname; testname.Append(KTest); TPtrC8 testdate(KINC107382TestCases[ii]); TBuf<150> buftestdate; buftestdate.Copy(testdate); testname.Append(buftestdate); iTestHarness->StartTestL(testname); TRAPD(err,date.SetDateL(KINC107382TestCases[ii])); iTestHarness->EndTest(err); User::LeaveIfError(err); } for (ii=0; ii< KInvalidDescriptorToIntTests; ++ii) { _LIT(KTest, "Test for fix DEF138868 - Case: "); TBuf<256> testname; testname.Append(KTest); TPtrC8 testInput(KInvalidDesToIntTestCases[ii]); TBuf<150> buftestInput; buftestInput.Copy(testInput); testname.Append(buftestInput); iTestHarness->StartTestL(testname); TInt err=0; InetProtTextUtils::ConvertDescriptorToInt(KInvalidDesToIntTestCases[ii], err); iTestHarness->EndTest(err); User::LeaveIfError(err); } }
int main(int argc, char **argv) { int i; struct node node = { -1 }; struct node video_node = { -1 }; struct node video_node2 = { -1 }; struct node radio_node = { -1, true }; struct node radio_node2 = { -1, true }; struct node vbi_node = { -1 }; struct node vbi_node2 = { -1 }; /* command args */ int ch; const char *device = NULL; const char *video_device = NULL; /* -d device */ const char *radio_device = NULL; /* -r device */ const char *vbi_device = NULL; /* -V device */ struct v4l2_capability vcap; /* list_cap */ char short_options[26 * 2 * 2 + 1]; int idx = 0; for (i = 0; long_options[i].name; i++) { if (!isalpha(long_options[i].val)) continue; short_options[idx++] = long_options[i].val; if (long_options[i].has_arg == required_argument) short_options[idx++] = ':'; } while (1) { int option_index = 0; short_options[idx] = 0; ch = getopt_long(argc, argv, short_options, long_options, &option_index); if (ch == -1) break; options[(int)ch] = 1; switch (ch) { case OptHelp: usage(); return 0; case OptSetDevice: video_device = optarg; if (video_device[0] >= '0' && video_device[0] <= '9' && strlen(video_device) <= 3) { static char newdev[20]; sprintf(newdev, "/dev/video%s", video_device); video_device = newdev; } break; case OptSetRadioDevice: radio_device = optarg; if (radio_device[0] >= '0' && radio_device[0] <= '9' && strlen(radio_device) <= 3) { static char newdev[20]; sprintf(newdev, "/dev/radio%s", radio_device); radio_device = newdev; } break; case OptSetVbiDevice: vbi_device = optarg; if (vbi_device[0] >= '0' && vbi_device[0] <= '9' && strlen(vbi_device) <= 3) { static char newdev[20]; sprintf(newdev, "/dev/vbi%s", vbi_device); vbi_device = newdev; } break; case OptNoWarnings: show_warnings = false; break; case OptVerbose: show_info = true; break; case ':': fprintf(stderr, "Option `%s' requires a value\n", argv[optind]); usage(); return 1; case '?': fprintf(stderr, "Unknown argument `%s'\n", argv[optind]); usage(); return 1; } } if (optind < argc) { printf("unknown arguments: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); usage(); return 1; } wrapper = options[OptUseWrapper]; struct utsname uts; int v1, v2, v3; uname(&uts); sscanf(uts.release, "%d.%d.%d", &v1, &v2, &v3); if (v1 == 2 && v2 == 6) kernel_version = v3; if (!video_device && !radio_device && !vbi_device) video_device = "/dev/video0"; if (video_device && (video_node.fd = test_open(video_device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", video_device, strerror(errno)); exit(1); } if (radio_device && (radio_node.fd = test_open(radio_device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", radio_device, strerror(errno)); exit(1); } if (vbi_device && (vbi_node.fd = test_open(vbi_device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", vbi_device, strerror(errno)); exit(1); } if (video_node.fd >= 0) { node.fd = video_node.fd; device = video_device; node.is_video = true; } else if (radio_node.fd >= 0) { node.fd = radio_node.fd; device = radio_device; node.is_radio = true; printf("is radio\n"); } else if (vbi_node.fd >= 0) { node.fd = vbi_node.fd; device = vbi_device; node.is_vbi = true; } node.device = device; doioctl(&node, VIDIOC_QUERYCAP, &vcap); if (vcap.capabilities & V4L2_CAP_DEVICE_CAPS) node.caps = vcap.device_caps; else node.caps = vcap.capabilities; if (node.caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_RDS_CAPTURE | V4L2_CAP_RADIO | V4L2_CAP_TUNER)) node.has_inputs = true; if (node.caps & (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_RDS_OUTPUT | V4L2_CAP_MODULATOR)) node.has_outputs = true; if (node.caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_RDS_CAPTURE)) node.can_capture = true; if (node.caps & (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_RDS_OUTPUT)) node.can_output = true; /* Information Opts */ if (kernel_version) printf("Running on 2.6.%d\n\n", kernel_version); printf("Driver Info:\n"); printf("\tDriver name : %s\n", vcap.driver); printf("\tCard type : %s\n", vcap.card); printf("\tBus info : %s\n", vcap.bus_info); printf("\tDriver version: %d.%d.%d\n", vcap.version >> 16, (vcap.version >> 8) & 0xff, vcap.version & 0xff); printf("\tCapabilities : 0x%08X\n", vcap.capabilities); printf("%s", cap2s(vcap.capabilities).c_str()); if (vcap.capabilities & V4L2_CAP_DEVICE_CAPS) { printf("\tDevice Caps : 0x%08X\n", vcap.device_caps); printf("%s", cap2s(vcap.device_caps).c_str()); } printf("\nCompliance test for device %s (%susing libv4l2):\n\n", device, wrapper ? "" : "not "); /* Required ioctls */ printf("Required ioctls:\n"); printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&node))); printf("\n"); /* Multiple opens */ printf("Allow for multiple opens:\n"); if (video_device) { video_node2 = node; printf("\ttest second video open: %s\n", ok((video_node2.fd = test_open(video_device, O_RDWR)) < 0)); if (video_node2.fd >= 0) { printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&video_node2))); printf("\ttest VIDIOC_G/S_PRIORITY: %s\n", ok(testPrio(&node, &video_node2))); node.node2 = &video_node2; } } if (radio_device) { radio_node2 = node; printf("\ttest second radio open: %s\n", ok((radio_node2.fd = test_open(radio_device, O_RDWR)) < 0)); if (radio_node2.fd >= 0) { printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&radio_node2))); printf("\ttest VIDIOC_G/S_PRIORITY: %s\n", ok(testPrio(&node, &radio_node2))); node.node2 = &video_node2; } } if (vbi_device) { vbi_node2 = node; printf("\ttest second vbi open: %s\n", ok((vbi_node2.fd = test_open(vbi_device, O_RDWR)) < 0)); if (vbi_node2.fd >= 0) { printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&vbi_node2))); printf("\ttest VIDIOC_G/S_PRIORITY: %s\n", ok(testPrio(&node, &vbi_node2))); node.node2 = &video_node2; } } printf("\n"); /* Debug ioctls */ printf("Debug ioctls:\n"); printf("\ttest VIDIOC_DBG_G/S_REGISTER: %s\n", ok(testRegister(&node))); printf("\ttest VIDIOC_LOG_STATUS: %s\n", ok(testLogStatus(&node))); printf("\n"); /* Input ioctls */ printf("Input ioctls:\n"); printf("\ttest VIDIOC_G/S_TUNER: %s\n", ok(testTuner(&node))); printf("\ttest VIDIOC_G/S_FREQUENCY: %s\n", ok(testTunerFreq(&node))); printf("\ttest VIDIOC_S_HW_FREQ_SEEK: %s\n", ok(testTunerHwSeek(&node))); printf("\ttest VIDIOC_ENUMAUDIO: %s\n", ok(testEnumInputAudio(&node))); printf("\ttest VIDIOC_G/S/ENUMINPUT: %s\n", ok(testInput(&node))); printf("\ttest VIDIOC_G/S_AUDIO: %s\n", ok(testInputAudio(&node))); printf("\tInputs: %d Audio Inputs: %d Tuners: %d\n", node.inputs, node.audio_inputs, node.tuners); printf("\n"); /* Output ioctls */ printf("Output ioctls:\n"); printf("\ttest VIDIOC_G/S_MODULATOR: %s\n", ok(testModulator(&node))); printf("\ttest VIDIOC_G/S_FREQUENCY: %s\n", ok(testModulatorFreq(&node))); printf("\ttest VIDIOC_ENUMAUDOUT: %s\n", ok(testEnumOutputAudio(&node))); printf("\ttest VIDIOC_G/S/ENUMOUTPUT: %s\n", ok(testOutput(&node))); printf("\ttest VIDIOC_G/S_AUDOUT: %s\n", ok(testOutputAudio(&node))); printf("\tOutputs: %d Audio Outputs: %d Modulators: %d\n", node.outputs, node.audio_outputs, node.modulators); printf("\n"); /* Control ioctls */ printf("Control ioctls:\n"); printf("\ttest VIDIOC_QUERYCTRL/MENU: %s\n", ok(testQueryControls(&node))); printf("\ttest VIDIOC_G/S_CTRL: %s\n", ok(testSimpleControls(&node))); printf("\ttest VIDIOC_G/S/TRY_EXT_CTRLS: %s\n", ok(testExtendedControls(&node))); printf("\ttest VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: %s\n", ok(testControlEvents(&node))); printf("\ttest VIDIOC_G/S_JPEGCOMP: %s\n", ok(testJpegComp(&node))); printf("\tStandard Controls: %d Private Controls: %d\n", node.std_controls, node.priv_controls); printf("\n"); /* I/O configuration ioctls */ printf("Input/Output configuration ioctls:\n"); printf("\ttest VIDIOC_ENUM/G/S/QUERY_STD: %s\n", ok(testStd(&node))); printf("\ttest VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: %s\n", ok(testTimings(&node))); printf("\ttest VIDIOC_DV_TIMINGS_CAP: %s\n", ok(testTimingsCap(&node))); printf("\n"); /* Format ioctls */ printf("Format ioctls:\n"); printf("\ttest VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: %s\n", ok(testEnumFormats(&node))); printf("\ttest VIDIOC_G/S_PARM: %s\n", ok(testParm(&node))); printf("\ttest VIDIOC_G_FBUF: %s\n", ok(testFBuf(&node))); printf("\ttest VIDIOC_G_FMT: %s\n", ok(testGetFormats(&node))); printf("\ttest VIDIOC_TRY_FMT: %s\n", ok(testTryFormats(&node))); printf("\ttest VIDIOC_S_FMT: %s\n", ok(testSetFormats(&node))); printf("\ttest VIDIOC_G_SLICED_VBI_CAP: %s\n", ok(testSlicedVBICap(&node))); printf("\n"); /* Codec ioctls */ printf("Codec ioctls:\n"); printf("\ttest VIDIOC_(TRY_)ENCODER_CMD: %s\n", ok(testEncoder(&node))); printf("\ttest VIDIOC_G_ENC_INDEX: %s\n", ok(testEncIndex(&node))); printf("\ttest VIDIOC_(TRY_)DECODER_CMD: %s\n", ok(testDecoder(&node))); printf("\n"); /* Buffer ioctls */ printf("Buffer ioctls:\n"); printf("\ttest VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: %s\n", ok(testReqBufs(&node))); //printf("\ttest read/write: %s\n", ok(testReadWrite(&node))); printf("\n"); /* TODO: VIDIOC_CROPCAP, VIDIOC_G/S_CROP, VIDIOC_G/S_SELECTION VIDIOC_S_FBUF/OVERLAY VIDIOC_QBUF/DQBUF/QUERYBUF/PREPARE_BUFS/EXPBUF VIDIOC_STREAMON/OFF */ /* Final test report */ test_close(node.fd); if (node.node2) test_close(node.node2->fd); printf("Total: %d, Succeeded: %d, Failed: %d, Warnings: %d\n", tests_total, tests_ok, tests_total - tests_ok, warnings); exit(app_result); }