void EditableFilterDialog::getConfigFromSettings() { // Restore settings: QSettings settings("GeoImageViewer_dot_com", "GIV"); if (settings.contains("EditableFilter/CMakePath")) { _model->setCMakePath(settings.value("EditableFilter/CMakePath").toString()); } if (settings.contains("EditableFilter/PATH")) { _model->setPATH(settings.value("EditableFilter/PATH").toString()); } #if (defined WIN32 || defined _WIN32 || defined WINCE) // Restore the generator if (settings.contains("EditableFilter/CMakeGenerator")) { _model->setCMakeGenerator(settings.value("EditableFilter/CMakeGenerator").toString()); } else { SD_TRACE("WIN32 : GENERATOR IS EMTPY"); configure(); } #endif }
rt_err_t rt_hw_sdcard_init(const char * spi_device_name) { int size; rt_uint32_t id, total_block; struct sdcard_device * sd; struct rt_device * device; sd = &_sdcard; device = &(sd->parent); lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO); /* open sd card file, if not exist, then create it */ sd->file = fopen(SDCARD_SIM, "rb+"); if (sd->file == NULL) { /* create a file to simulate sd card */ sd->file = fopen(SDCARD_SIM, "wb+"); fseek(sd->file, 0, SEEK_END); size = ftell(sd->file); fseek(sd->file, 0, SEEK_SET ); if (size < SDCARD_SIZE) { int i; unsigned char* ptr; ptr = (unsigned char*) malloc (1024 * 1024); if (ptr == NULL) { SD_TRACE("malloc error, no memory!\n"); return RT_ERROR; } memset(ptr, 0x0, 1024 * 1024); fseek(sd->file, 0, SEEK_SET); for(i=0; i<(SDCARD_SIZE / (1024*1024)); i++) fwrite(ptr, 1024 * 1024, 1, sd->file); free(ptr); } } fseek(sd->file, 0, SEEK_SET); device->type = RT_Device_Class_Block; device->init = rt_sdcard_init; device->open = rt_sdcard_open; device->close = rt_sdcard_close; device->read = rt_sdcard_read; device->write = rt_sdcard_write; device->control = rt_sdcard_control; device->user_data = NULL; rt_device_register(device, "sd0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE); return RT_EOK; }
//------------------------------------------------------------------------------ bool SdSpiCard::writeBlock(uint32_t blockNumber, const uint8_t* src) { SD_TRACE("WB", blockNumber); // use address if not SDHC card if (type() != SD_CARD_TYPE_SDHC) { blockNumber <<= 9; } if (cardCommand(CMD24, blockNumber)) { error(SD_CARD_ERROR_CMD24); goto fail; } if (!writeData(DATA_START_BLOCK, src)) { goto fail; } #if CHECK_FLASH_PROGRAMMING // wait for flash programming to complete if (!waitNotBusy(SD_WRITE_TIMEOUT)) { error(SD_CARD_ERROR_WRITE_TIMEOUT); goto fail; } // response is r2 so get and check two bytes for nonzero if (cardCommand(CMD13, 0) || spiReceive()) { error(SD_CARD_ERROR_CMD13); goto fail; } #endif // CHECK_PROGRAMMING spiStop(); return true; fail: spiStop(); return false; }
void EditableFilterDialog::configure() { SD_TRACE("Start build configuration dialog"); _configDialog->setCMakePath(_model->getCMakePath()); _configDialog->setPATH(_model->getPATH()); _configDialog->setGenerator(_model->getCMakeGenerator()); if (_configDialog->exec() == QDialog::Accepted) { if (_model->getCMakeGenerator() != _configDialog->getGenerator()) { if (!_model->removeBuildCache()) { SD_ERR(tr("Failed to remove build cache. Please, remove manually the folder 'Build' at '<INSTALLATION_FOLDER>/Resources/Build'")); return; } } _model->setCMakePath(_configDialog->getCMakePath()); _model->setPATH(_configDialog->getPATH()); _model->setCMakeGenerator(_configDialog->getGenerator()); setConfigToSettings(); _model->runTestCmake(); } }
/* position: block page address, not bytes address * buffer: * size : how many blocks */ static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const void* buffer, rt_size_t size) { struct sdcard_device * sd; int result = 0; SD_TRACE("sst write: pos %d, size %d\n", position, size); rt_mutex_take(lock, RT_WAITING_FOREVER); sd = SDCARD_DEVICE(device); fseek(sd->file, position * SECTOR_SIZE, SEEK_SET); result = fwrite(buffer, size * SECTOR_SIZE, 1, sd->file); if (result < 0) goto _err; rt_mutex_release(lock); return size; _err: SD_TRACE("sd write errors!\n"); rt_mutex_release(lock); return 0; }
void BaseViewer::viewportInfo() { #ifdef SHOW_VIEWPORT_INFO // display visible scene zone QRect wr = _ui->_view->viewport()->rect(); SD_TRACE(QString("view rect : (%1, %2) | %3, %4") .arg(wr.x()) .arg(wr.y()) .arg(wr.width()) .arg(wr.height())); QRectF r = _ui->_view->mapToScene(wr).boundingRect(); SD_TRACE(QString("visible scene rect : (%1, %2) | %3, %4") .arg(r.x()) .arg(r.y()) .arg(r.width()) .arg(r.height())); double sx = _ui->_view->matrix().m11(); double sy = _ui->_view->matrix().m22(); SD_TRACE(QString("view scale : %1, %2").arg(sx).arg(sy)); #endif }
//------------------------------------------------------------------------------ bool SdSpiCard::readStart(uint32_t blockNumber) { SD_TRACE("RS", blockNumber); if (type() != SD_CARD_TYPE_SDHC) { blockNumber <<= 9; } if (cardCommand(CMD18, blockNumber)) { error(SD_CARD_ERROR_CMD18); goto fail; } // spiStop(); return true; fail: spiStop(); return false; }
void addNoise(cv::Mat &image) { if (image.channels() > 1) { SD_TRACE("addNoise : image should have single channel"); return; } int initDepth=image.depth(); if (initDepth < CV_32F) image.convertTo(image, CV_32F); cv::Mat noise(image.rows, image.cols, image.type()); cv::randn(noise, 100, 25); image = image + noise; if (initDepth == CV_8U) ImageCommon::convertTo8U(image, image); }
//------------------------------------------------------------------------------ bool SdSpiCard::readBlock(uint32_t blockNumber, uint8_t* dst) { SD_TRACE("RB", blockNumber); // use address if not SDHC card if (type() != SD_CARD_TYPE_SDHC) { blockNumber <<= 9; } if (cardCommand(CMD17, blockNumber)) { error(SD_CARD_ERROR_CMD17); goto fail; } if (!readData(dst, 512)) { goto fail; } spiStop(); return true; fail: spiStop(); return false; }
//------------------------------------------------------------------------------ bool SdSpiCard::writeStart(uint32_t blockNumber, uint32_t eraseCount) { SD_TRACE("WS", blockNumber); // send pre-erase count if (cardAcmd(ACMD23, eraseCount)) { error(SD_CARD_ERROR_ACMD23); goto fail; } // use address if not SDHC card if (type() != SD_CARD_TYPE_SDHC) { blockNumber <<= 9; } if (cardCommand(CMD25, blockNumber)) { error(SD_CARD_ERROR_CMD25); goto fail; } return true; fail: spiStop(); return false; }
void help() { SD_TRACE("Usage : BoWC_Example train_data_path test_data_path"); SD_TRACE(" where image_data_path is a path with *.jpg, *.png, *.tif images"); SD_TRACE("Example : BoWC_Example C:/Temp/"); }
void help() { SD_TRACE("Usage : FreqFiltering_Example image_data_path"); SD_TRACE(" where image_data_path is a path with *.jpg, *.png, *.tif images"); SD_TRACE("Example : FreqFiltering_Example C:/Temp/"); }