void MatCache::set_yuv422(uint8_t *y, int rs_y, uint8_t *u, int rs_u, uint8_t *v, int rs_v) { invalidate(); cv::Mat y_mat(height, width, CV_8UC1, (void*)y, rs_y); update_image("gray_8u", y_mat); cv::Mat u_mat(height / 2, width / 2, CV_8UC1, (void*)u, rs_u); update_image("yuv422_u_8u", u_mat); cv::Mat v_mat(height / 2, width / 2, CV_8UC1, (void*)v, rs_v); update_image("yuv422_v_8u", v_mat); }
void RecursiveRLSCholUpdateWrapper<T>::update(const gMat2D<T> &X, const gMat2D<T> &y) { if(!this->trainedModel()) throw gException("Error, Train Model First"); RLSPrimalRecUpdateCholesky<T> optimizer; const unsigned long d = X.getSize(); const unsigned long t = y.getSize(); gMat2D<T>X_mat(1, d); copy(X_mat.getData(), X.getData(), d); gMat2D<T>y_mat(1, t); copy(y_mat.getData(), y.getData(), t); GurlsOptionsList* ret = optimizer.execute(X_mat, y_mat, *(this->opt)); this->opt->removeOpt("optimizer"); this->opt->addOpt("optimizer", ret); }
void RecursiveRLSWrapper<T>::update(const gVec<T> &X, const gVec<T> &y) { if(!this->trainedModel()) throw gException("Error, Train Model First"); RLSPrimalRecUpdate<T> optimizer; const unsigned long d = X.getSize(); const unsigned long t = y.getSize(); gMat2D<T>X_mat(1, d); copy(X_mat.getData(), X.getData(), d); gMat2D<T>y_mat(1, t); copy(y_mat.getData(), y.getData(), t); GurlsOptionsList* ret = optimizer.execute(X_mat, y_mat, *(this->opt)); this->opt->removeOpt("optimizer"); this->opt->addOpt("optimizer", ret); ++nTot; gMat2D<T>* xtx = new gMat2D<T>(d,d); gMat2D<T>* xty = new gMat2D<T>(d,t); dot(X.getData(), X.getData(), xtx->getData(), 1, d, 1, d, d, d, CblasTrans, CblasNoTrans, CblasColMajor); dot(X.getData(), y.getData(), xty->getData(), 1, d, 1, t, d, t, CblasTrans, CblasNoTrans, CblasColMajor); GurlsOptionsList* kernel = this->opt->template getOptAs<GurlsOptionsList>("kernel"); const gMat2D<T>& XtX = kernel->getOptValue<OptMatrix<gMat2D<T> > >("XtX"); const gMat2D<T>& Xty = kernel->getOptValue<OptMatrix<gMat2D<T> > >("Xty"); axpy(d*d, (T)1.0, XtX.getData(), 1, xtx->getData(), 1); axpy(d*t, (T)1.0, Xty.getData(), 1, xty->getData(), 1); kernel->removeOpt("XtX"); kernel->addOpt("XtX", new OptMatrix<gMat2D<T> >(*xtx)); kernel->removeOpt("Xty"); kernel->addOpt("Xty", new OptMatrix<gMat2D<T> >(*xty)); unsigned long proportion = static_cast<unsigned long>(gurls::round(1.0/this->opt->getOptAsNumber("hoproportion"))); if(nTot % proportion == 0) { const gMat2D<T>& Xva = kernel->getOptValue<OptMatrix<gMat2D<T> > >("Xva"); const gMat2D<T>& yva = kernel->getOptValue<OptMatrix<gMat2D<T> > >("yva"); const unsigned long nva = Xva.rows(); const unsigned long nva_new = nva+1; gMat2D<T>* Xva_new = new gMat2D<T>(nva_new, d); const T* old_it = Xva.getData(); T* new_it = Xva_new->getData(); for(const T* end = new_it+(nva_new*d); new_it< end; old_it+=nva, new_it +=nva_new) copy(new_it, old_it, nva); copy(Xva_new->getData()+nva, X.getData(), d, nva_new, 1); kernel->removeOpt("Xva"); kernel->addOpt("Xva", new OptMatrix<gMat2D<T> >(*Xva_new)); gMat2D<T>* yva_new = new gMat2D<T>(nva_new, t); old_it = yva.getData(); new_it = yva_new->getData(); for(const T* end = new_it+(nva_new*t); new_it< end; old_it+=nva, new_it +=nva_new) copy(new_it, old_it, nva); copy(yva_new->getData()+nva, y.getData(), t, nva_new, 1); kernel->removeOpt("yva"); kernel->addOpt("yva", new OptMatrix<gMat2D<T> >(*yva_new)); } }