frenzy::dom::Nodep frenzy::dom::Attr::cloneNode(bool deep) const { Attrp ret = Attr::create(name); copyTo(ret, deep); return ret; }
void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const { bool noScale = std::fabs(alpha - 1) < DBL_EPSILON && std::fabs(beta) < DBL_EPSILON; int stype = type(), cn = CV_MAT_CN(stype); if( _type < 0 ) _type = _dst.fixedType() ? _dst.type() : stype; else _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), cn); int sdepth = CV_MAT_DEPTH(stype), ddepth = CV_MAT_DEPTH(_type); if( sdepth == ddepth && noScale ) { copyTo(_dst); return; } #ifdef HAVE_OPENCL bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; bool needDouble = sdepth == CV_64F || ddepth == CV_64F; if( dims <= 2 && cn && _dst.isUMat() && ocl::useOpenCL() && ((needDouble && doubleSupport) || !needDouble) ) { int wdepth = std::max(CV_32F, sdepth), rowsPerWI = 4; char cvt[2][40]; ocl::Kernel k("convertTo", ocl::core::convert_oclsrc, format("-D srcT=%s -D WT=%s -D dstT=%s -D convertToWT=%s -D convertToDT=%s%s%s", ocl::typeToStr(sdepth), ocl::typeToStr(wdepth), ocl::typeToStr(ddepth), ocl::convertTypeStr(sdepth, wdepth, 1, cvt[0]), ocl::convertTypeStr(wdepth, ddepth, 1, cvt[1]), doubleSupport ? " -D DOUBLE_SUPPORT" : "", noScale ? " -D NO_SCALE" : "")); if (!k.empty()) { UMat src = *this; _dst.create( size(), _type ); UMat dst = _dst.getUMat(); float alphaf = (float)alpha, betaf = (float)beta; ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src), dstarg = ocl::KernelArg::WriteOnly(dst, cn); if (noScale) k.args(srcarg, dstarg, rowsPerWI); else if (wdepth == CV_32F) k.args(srcarg, dstarg, alphaf, betaf, rowsPerWI); else k.args(srcarg, dstarg, alpha, beta, rowsPerWI); size_t globalsize[2] = { (size_t)dst.cols * cn, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI }; if (k.run(2, globalsize, NULL, false)) { CV_IMPL_ADD(CV_IMPL_OCL); return; } } } #endif Mat m = getMat(ACCESS_READ); m.convertTo(_dst, _type, alpha, beta); }
HBaseStyle* HImageStyle::clone() { HImageStyle* style = new HImageStyle(HObjectInfo(styleId(),""),parent()); copyTo(style); return style; }
boost::shared_ptr<IParticleSystem> PointArrayParticleSystem::clone() { PointArrayParticleSystem* ps = new PointArrayParticleSystem(); copyTo(*ps); ps->m_eds = m_eds; ps->m_parray = m_parray; boost::shared_ptr<IParticleSystem> ptr(ps); #ifdef PHYSICS_PHYSX #ifndef NX_DISABLE_FLUIDS if(!fluid && physics && (m_eds->physicsType == GenParticleSystemEditables::PHYSICS_TYPE_FLUID || m_eds->physicsType == GenParticleSystemEditables::PHYSICS_TYPE_FLUID_INTERACTION)) { int collGroup = PHYSICS_COLLISIONGROUP_FLUIDS; if (m_eds->fluidDetailCollisionGroup) { collGroup = PHYSICS_COLLISIONGROUP_FLUIDS_DETAILED; } fluid = physics->createFluid(m_eds->physicsType - 2, m_eds->maxParticles * m_eds->fluidMaxEmitterAmount, m_eds->fluidStaticRestitution, m_eds->fluidStaticRestitution, m_eds->fluidDynamicRestitution, m_eds->fluidDynamicAdhesion, m_eds->fluidDamping, m_eds->fluidStiffness, m_eds->fluidViscosity, m_eds->fluidKernelRadiusMultiplier, m_eds->fluidRestParticlesPerMeter, m_eds->fluidRestDensity, m_eds->fluidMotionLimit, m_eds->fluidPacketSizeMultiplier, collGroup); if(fluid) m_render_fluid_parts.reset(new std::vector<Particle> (m_eds->maxParticles * m_eds->fluidMaxEmitterAmount)); } ps->fluid = fluid; ps->m_render_fluid_parts = m_render_fluid_parts; #endif #endif return ptr; }
bool ServerConfigurationDialog::testConnection() { bool okay(false); if (!copyTo(&m_currentConfiguration)) return okay; switch (m_currentConfiguration.connection()) { case ServerConfiguration::Local: QMsgBox::information(this, "IQmol", "Local connection just fine"); break; case ServerConfiguration::SSH: okay = testSshConnection(m_currentConfiguration); break; case ServerConfiguration::HTTP: case ServerConfiguration::HTTPS: okay = testHttpConnection(m_currentConfiguration); break; } if (okay) { QMsgBox::information(0, "IQmol", "Connection successful"); m_tested = true; } return okay; }
inline GpuMat GpuMat::clone() const { GpuMat m; copyTo(m); return m; }
uint32 AudioBuffer::copyTo( AudioBuffer& target, uint32* pioFromFrame, uint32* pioTargetFrame) const { return copyTo(target, pioFromFrame, pioTargetFrame, m_frames); }
ISecUser * CLdapSecUser::clone() { CLdapSecUser* newuser = new CLdapSecUser(m_name.get(), m_pw.get()); if(newuser) copyTo(*newuser); return newuser; }
LeafMatchExpression* InMatchExpression::shallowClone() const { InMatchExpression* next = new InMatchExpression(); copyTo( next ); if ( getTag() ) { next->setTag(getTag()->clone()); } return next; }
void View::onRefresh(RectList *rects, M4Surface *destSurface) { assert(destSurface); if (rects == NULL) // No rect list specified, so copy entire surface copyTo(destSurface, _coords.left, _coords.top, _transparent ? 0 : -1); else { // Loop through the set of specified rectangles RectList::iterator i; for (i = rects->begin(); i != rects->end(); ++i) { Common::Rect &destRect = *i; Common::Rect srcBounds(destRect.left - _coords.left, destRect.top - _coords.top, destRect.right - _coords.left, destRect.bottom - _coords.top); copyTo(destSurface, srcBounds, destRect.left, destRect.top, _transparent ? 0 : -1); } } }
ISecResourceList * clone() { ISecResourceList* _newList = new CSecurityResourceList(m_name.get()); if(!_newList) return NULL; copyTo(*_newList); return _newList; }
std::unique_ptr<MatchExpression> InMatchExpression::shallowClone() const { std::unique_ptr<InMatchExpression> next = stdx::make_unique<InMatchExpression>(); copyTo(next.get()); if (getTag()) { next->setTag(getTag()->clone()); } return std::move(next); }
ISecResourceList * CLdapSecResourceList::clone() { CLdapSecResourceList* _newList = new CLdapSecResourceList(m_name.get()); if(!_newList) return NULL; copyTo(*_newList); return _newList; }
// Apply data to current bool CAreaConfiguration::restore(CParameterBlackboard* pMainBlackboard, bool bSync, list<string>* plstrError) const { assert(_bValid); copyTo(pMainBlackboard, _pConfigurableElement->getOffset()); // Synchronize if required return !bSync || _pSyncerSet->sync(*pMainBlackboard, false, plstrError); }
ISecUser * clone() { //DBGLOG("Beginning of clone()"); CSecureUser* newuser = new CSecureUser(m_name.str(), m_pw.str()); //DBGLOG("Before copy to"); if(newuser) copyTo(*newuser); //DBGLOG("After copy to"); return newuser; }
cv::Mat EMat::AppendRight(cv::Mat &src, cv::Mat &dst) { assert(src.rows == rows); if ((dst.rows < src.rows) || (dst.cols < src.cols + cols)) dst.create(src.rows, src.cols + cols, type()); cv::Mat left = dst(cv::Range(0, src.rows), cv::Range(0, cols)); cv::Mat right = dst(cv::Range(0, src.rows), cv::Range(cols, src.cols + cols)); copyTo(left); src.copyTo(right); return dst(cv::Range(0, rows), cv::Range(0, src.cols + cols)); }
cv::Mat EMat::AppendBottom(cv::Mat &src, cv::Mat &dst) { assert(src.cols == cols); if ((dst.cols < src.cols) || (dst.rows < src.rows + rows)) dst.create(src.rows + rows, src.cols, type()); cv::Mat top = dst(cv::Range(0, rows), cv::Range(0, cols)); cv::Mat bottom = dst(cv::Range(rows, src.rows + rows), cv::Range(0, cols)); copyTo(top); src.copyTo(bottom); return dst(cv::Range(0, src.rows + rows), cv::Range(0, cols)); }
void Mat::copyTo( Mat& dst, const Mat& mask ) const { if( !mask.data ) { copyTo(dst); return; } uchar* data0 = dst.data; dst.create( size(), type() ); if( dst.data != data0 ) // do not leave dst uninitialized dst = Scalar(0); getCopyMaskFunc((int)elemSize())(*this, dst, mask); }
void Surface::copyTo(Surface *dest, uint16 x, uint16 y) { if ((x == 0) && (dest->width() == _width)) { // Use fast data transfer uint32 dataSize = dest->data().size() - (y * _width); if (dataSize > _data->size()) dataSize = _data->size(); dest->data().copyFrom(_data, 0, y * _width, dataSize); } else { // Use slower transfer Common::Rect rect; rect.left = 0; rect.top = 0; rect.right = _width-1; rect.bottom = _height-1; copyTo(dest, rect, x, y); } }
int main(int argc, char **argv) { std::vector<cv::ogl::Texture2D> images; if (argc == 1) { fprintf(stderr, "usage: %s <images ...>\n" " cycle between given images\n", argv[0]); return -1; } cv::namedWindow("img", cv::WINDOW_OPENGL); images.resize(argc - 1); for (int i = 1; i < argc; i ++) { auto img = cv::imread(argv[i], CV_LOAD_IMAGE_COLOR); if (img.empty()) { fprintf(stderr, "failed to load %s: %m\n", argv[i]); return -1; } cv::Mat img1(img.rows + 2, img.cols + 2, CV_8UC3, cv::Scalar{0}); img1.at<cv::Vec3b>(0, 0) = {0, 0, 255}; img1.at<cv::Vec3b>(0, img.cols + 1) = {0, 255, 0}; img1.at<cv::Vec3b>(img.rows + 1, 0) = {255, 0, 0}; img1.at<cv::Vec3b>(img.rows + 1, img.cols + 1) = {255, 0, 0}; img.copyTo(img1(cv::Rect(1, 1, img.cols, img.rows))); img = img1; cv::resize(img, img, {0, 0}, SCALE_FACTOR, SCALE_FACTOR, cv::INTER_NEAREST); images[i - 1].copyFrom(img); } cv::resizeWindow("img", images[0].cols(), images[0].rows()); int nr_frame = 0; size_t idx = 0; double fps_time = get_time(); for (; ; ) { nr_frame ++; if (nr_frame >= 100) { auto now = get_time(); printf("fps: %.2f\n", nr_frame / (now - fps_time)); fps_time = now; nr_frame = 0; } cv::imshow("img", images[idx ++]); if (idx == images.size()) idx = 0; if ((cv::waitKey(1) & 0xFF) == 'q') break; } cv::destroyWindow("img"); }
void ServerConfigurationDialog::on_exportButton_clicked(bool) { if (!copyTo(&m_currentConfiguration)) return; QString filePath(QDir::homePath()); filePath += "/iqmol_server.cfg"; filePath = QFileDialog::getSaveFileName(this, tr("Save File"), filePath, tr("Configuration Files (*.cfg)")); if (filePath.isEmpty()) return; Data::YamlNode node(m_currentConfiguration.toYamlNode()); if (!node.saveToFile(filePath)) { QMsgBox::warning(this, "IQmol", "Failed to export server configuration"); } }
//! copies this surface into another, scaling it to the target image size // note: this is very very slow. void CImage::copyToScaling(IImage* target) { if (!target) return; const core::dimension2d<u32>& targetSize = target->getDimension(); if (targetSize==Size) { copyTo(target); return; } copyToScaling(target->lock(), targetSize.Width, targetSize.Height, target->getColorFormat()); target->unlock(); }
void UMat::copyTo(OutputArray _dst, InputArray _mask) const { if( _mask.empty() ) { copyTo(_dst); return; } #ifdef HAVE_OPENCL int cn = channels(), mtype = _mask.type(), mdepth = CV_MAT_DEPTH(mtype), mcn = CV_MAT_CN(mtype); CV_Assert( mdepth == CV_8U && (mcn == 1 || mcn == cn) ); if (ocl::useOpenCL() && _dst.isUMat() && dims <= 2) { UMatData * prevu = _dst.getUMat().u; _dst.create( dims, size, type() ); UMat dst = _dst.getUMat(); bool haveDstUninit = false; if( prevu != dst.u ) // do not leave dst uninitialized haveDstUninit = true; String opts = format("-D COPY_TO_MASK -D T1=%s -D scn=%d -D mcn=%d%s", ocl::memopTypeToStr(depth()), cn, mcn, haveDstUninit ? " -D HAVE_DST_UNINIT" : ""); ocl::Kernel k("copyToMask", ocl::core::copyset_oclsrc, opts); if (!k.empty()) { k.args(ocl::KernelArg::ReadOnlyNoSize(*this), ocl::KernelArg::ReadOnlyNoSize(_mask.getUMat()), haveDstUninit ? ocl::KernelArg::WriteOnly(dst) : ocl::KernelArg::ReadWrite(dst)); size_t globalsize[2] = { cols, rows }; if (k.run(2, globalsize, NULL, false)) { CV_IMPL_ADD(CV_IMPL_OCL); return; } } } #endif Mat src = getMat(ACCESS_READ); src.copyTo(_dst, _mask); }
void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const { bool noScale = std::fabs(alpha - 1) < DBL_EPSILON && std::fabs(beta) < DBL_EPSILON; int stype = type(), cn = CV_MAT_CN(stype); if( _type < 0 ) _type = _dst.fixedType() ? _dst.type() : stype; else _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), cn); int sdepth = CV_MAT_DEPTH(stype), ddepth = CV_MAT_DEPTH(_type); if( sdepth == ddepth && noScale ) { copyTo(_dst); return; } bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; bool needDouble = sdepth == CV_64F || ddepth == CV_64F; if( dims <= 2 && cn && _dst.isUMat() && ocl::useOpenCL() && ((needDouble && doubleSupport) || !needDouble) ) { char cvt[40]; ocl::Kernel k("convertTo", ocl::core::convert_oclsrc, format("-D srcT=%s -D dstT=%s -D convertToDT=%s%s", ocl::typeToStr(sdepth), ocl::typeToStr(ddepth), ocl::convertTypeStr(CV_32F, ddepth, 1, cvt), doubleSupport ? " -D DOUBLE_SUPPORT" : "")); if (!k.empty()) { UMat src = *this; _dst.create( size(), _type ); UMat dst = _dst.getUMat(); float alphaf = (float)alpha, betaf = (float)beta; k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst, cn), alphaf, betaf); size_t globalsize[2] = { dst.cols * cn, dst.rows }; if (k.run(2, globalsize, NULL, false)) return; } } Mat m = getMat(ACCESS_READ); m.convertTo(_dst, _type, alpha, beta); }
void ServerConfigurationDialog::verify() { if (!copyTo(&m_currentConfiguration)) return; /* don't bother with the testing at the moment, it is just annoying if (!m_tested && !m_dialog.localRadioButton->isChecked()) { QString msg("Would you like to try connecting to the server?"); if (QMsgBox::question(this, "IQmol", msg, QMessageBox::No | QMessageBox::Yes) == QMessageBox::Yes) { if (!testConnection()) return; } } */ m_originalConfiguration = m_currentConfiguration; accept(); }
Matrix Matrix::mask(Contours contours) { Matrix masked = clone(); if (contours.size() > 0) { // Create mask cv::Mat mask = cv::Mat::zeros(size(), CV_8UC1); // Draw contours onto the mask so they are not removed for (int i = 0; i < contours.size(); ++i) { cv::drawContours(mask, contours, i, cv::Scalar(255), CV_FILLED); } masked = cv::Mat(cv::Mat::zeros(size(), type())); copyTo(masked, mask); } return masked; }
void CCanvasObserver::SetCanvasMat(cv::Mat graymat) { COUNTER_HELPER(CCanvasObserver_SetCanvasMat); /// remove border auto rect = _GetRectWithoutBorder(graymat); auto noborder = cv::Mat(graymat, rect); /// scale to defined size cv::resize(noborder, m_matCanvas, cv::Size(CANVAS_SCALETO_WIDTH, CANVAS_SCALETO_HEIGHT)); /// remove ground auto noground = cv::Mat(m_matCanvas, cv::Rect(0, 0, CANVAS_SCALETO_WIDTH, m_matGrayBg.rows)); /// remove background cv::Mat bgmask; cv::absdiff(noground, m_matGrayBg, bgmask); noground.copyTo(m_matCanvas, bgmask); }
//--------- void Register::addAddon(string addonName) { if (this->addonList.find(addonName) != this->addonList.end()) { ofLogWarning("ofxAddons::Register::addAddon") << "Addon [" << addonName << "] has already been added to the ofxAssets::Register."; return; } //whilst we're in debug build mode, we'll actually copy over the assets from the addon's folder #if defined(__DEBUGGING__) || defined(_DEBUG) //if we're still debugging in the build location, copy in latest assets auto checkDir = ofDirectory("../../../../../addons/" + addonName + "/data/assets/" + addonName); if (checkDir.exists()) { ofLogNotice("ofxAssets") << "Copying in addon files from " << checkDir.getOriginalDirectory(); checkDir.copyTo("assets/" + addonName, true, true); } else { ofLogNotice("ofxAssets") << "Cannot copy in addon assets since folder doesn't exist : " << checkDir.getOriginalDirectory(); } #endif this->addonList.insert(addonName); this->loadAssets(addonName); }
SimplexData& SimplexData::doPivot(int pivotrow, int pivotcol) { SimplexData *res = new SimplexData(); // Make a copy copyTo(*res); // Do the pivot operation in the copy for (int i=0; i<m+1; ++i) { if (i != pivotrow) { for (int j=0; j<m+n+1; ++j) { if (j != pivotcol) { res->tab[i][j] = (tab[i][j] * tab[pivotrow][pivotcol] - tab[i][pivotcol] * tab[pivotrow][j]) / tab[pivotrow][pivotcol]; } } } } for (int i=0; i<m+1; ++i) { if (i != pivotrow) res->tab[i][pivotcol] = 0/*-1 * tab[i][pivotcol] / tab[pivotrow][pivotcol]*/; } for (int j=0; j<m+n+1; ++j) { if (j != pivotcol) res->tab[pivotrow][j] = tab[pivotrow][j] / tab[pivotrow][pivotcol]; } res->tab[pivotrow][pivotcol] = 1; // Adjust row label in the copy as well res->rowlabels[pivotrow] = collabels[pivotcol]; // Fix zeros, those -0.0 are ugly as hell res->fixZeros(); // ... and return the copy return *res; }
cv::Mat EMat::prepad(int x_padsize, int y_padsize, pad_dir dir, const cv::Scalar &padval) { cv::Mat new_mat; assert(x_padsize || y_padsize); // Create a new matrix of the appropriate size and initialize it if ((dir == pre) || (dir == post)) new_mat.create(rows + y_padsize, cols + x_padsize, type()); else new_mat.create(rows + (y_padsize * 2), cols + (x_padsize * 2), type()); new_mat = padval; // Place the old matrix in the appropriate location cv::Mat target; if (dir == post) target = new_mat(cv::Rect(0, 0, cols, rows)); else // Both pre and both have the same target rect target = new_mat(cv::Rect(x_padsize, y_padsize, cols, rows)); copyTo(target); return new_mat; }