void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { const QRect screen = effects->virtualScreenGeometry(); if (shouldBlur(w, mask, data)) { QRegion shape = region & blurRegion(w).translated(w->pos()) & screen; const bool translated = data.xTranslation() || data.yTranslation(); // let's do the evil parts - someone wants to blur behind a transformed window if (translated) { shape = shape.translated(data.xTranslation(), data.yTranslation()); shape = shape & region; } if (!shape.isEmpty()) { if (m_shouldCache && !translated) { doCachedBlur(w, region, data.opacity()); } else { doBlur(shape, screen, data.opacity()); } } } // Draw the window over the blurred area effects->drawWindow(w, mask, region, data); }
int ARTracker::processFrame(cv::Mat& frame){ std::vector<std::vector<cv::Point> > contours; std::vector<ARMarker> potentialMarkers; // flush out previously detected markers _detectedMarkers.clear(); doGreyScale(_greyMat, frame); if( isBlurring() ){ doBlur(_greyMat, _greyMat); } doThreshold(_binaryMat, _greyMat); doFindContours(contours, _binaryMat); doFindPotentialMarkers(potentialMarkers, contours, _binaryMat); doFindMarkers(_detectedMarkers, potentialMarkers, _binaryMat); doSubpixelAccuracy(_detectedMarkers, _greyMat); doEstimatePose(_detectedMarkers); processDebugRequest(frame, _greyMat, _binaryMat, contours, potentialMarkers, _detectedMarkers); return _detectedMarkers.size(); }
void BlurEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity) { const QRect screen = effects->virtualScreenGeometry(); bool valid = target->valid() && shader && shader->isValid(); QRegion shape = frame->geometry().adjusted(-5, -5, 5, 5) & screen; if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect()) && frame->style() != EffectFrameNone) { doBlur(shape, screen, opacity * frameOpacity); } effects->paintEffectFrame(frame, region, opacity, frameOpacity); }
void BlurUniform::blur(TimeValue t, CompMap *pCompMap, Bitmap *bm, RenderGlobalContext *gc) { // get source bitmap data int type; mp_srcAlpha = (WORD*)bm->GetAlphaPtr(&type); mp_srcMap = (WORD*)bm->GetStoragePtr(&type); assert(type == BMM_TRUE_48); // if source bitmap has changed since last call if ( m_lastBMModifyID != bm->GetModifyID() ) { m_lastBMModifyID = bm->GetModifyID(); m_blurValid = false; if ( (bm->Width() != m_imageW) || (bm->Height() != m_imageH) ) { m_imageW = bm->Width(); m_imageH = bm->Height(); m_imageSz = m_imageW * m_imageH; } } // get ui parameters float fTemp; mp_blurMgr->getBlurValue(prmUnifPixRad, t, fTemp, FOREVER); LimitValue(fTemp, 0.0f, 1000.0f); // mjm - 9.30.99 m_pixRad = (int)( 0.5*floor( max(m_imageW, m_imageH)*(fTemp*PERCENT2DEC) ) ); mp_blurMgr->getBlurValue(prmUnifAlpha, t, m_affectAlpha, FOREVER); mp_blurMgr->getSelValue(prmGenBrightType, t, m_brightenType, FOREVER); // setup buffers if (m_imageSz > m_mapSz) { if (mp_scratchMap) delete[] mp_scratchMap; mp_scratchMap = new AColor[m_imageSz]; if (mp_blurCache) delete[] mp_blurCache; mp_blurCache = new AColor[m_imageSz]; m_mapSz = m_imageSz; } m_blurValid = doBlur(pCompMap, mp_srcMap, mp_srcMap, mp_srcAlpha, (m_affectAlpha) ? mp_srcAlpha : NULL); };
void FreeDistortBaseFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri) { if (!m_input.isConnected()) return; //Upon deactivation, this fx does nothing. if (m_deactivate->getValue()) { m_input->compute(tile, frame, ri); return; } //Get the source quad TPointD p00_b = m_p00_b->getValue(frame); TPointD p10_b = m_p10_b->getValue(frame); TPointD p01_b = m_p01_b->getValue(frame); TPointD p11_b = m_p11_b->getValue(frame); //Get destination quad TPointD p00_a = m_p00_a->getValue(frame); TPointD p10_a = m_p10_a->getValue(frame); TPointD p01_a = m_p01_a->getValue(frame); TPointD p11_a = m_p11_a->getValue(frame); if (m_isCastShadow) { //Shadows are mirrored tswap(p00_a, p01_a); tswap(p10_a, p11_a); } //Get requested tile's geometry TRasterP tileRas(tile.getRaster()); TRectD tileRect(convert(tileRas->getBounds()) + tile.m_pos); //Call transform to get the minimal rectOnInput TRectD inRect; TRenderSettings riNew; TRectD inBBox; safeTransform(frame, 0, tileRect, ri, inRect, riNew, inBBox); //Intersect with the bbox inRect *= inBBox; if (myIsEmpty(inRect)) return; double scale = ri.m_affine.a11; double downBlur = m_downBlur->getValue(frame) * scale; double upBlur = m_upBlur->getValue(frame) * scale; int brad = tceil(tmax(downBlur, upBlur)); inRect = inRect.enlarge(brad); TDimension inRectSize(tceil(inRect.getLx()), tceil(inRect.getLy())); TTile inTile; m_input->allocateAndCompute(inTile, inRect.getP00(), inRectSize, tileRas, frame, riNew); TPointD inTilePosRi = inTile.m_pos; //Update quads by the scale factors p00_b = riNew.m_affine * p00_b; p10_b = riNew.m_affine * p10_b; p01_b = riNew.m_affine * p01_b; p11_b = riNew.m_affine * p11_b; p00_a = ri.m_affine * p00_a; p10_a = ri.m_affine * p10_a; p01_a = ri.m_affine * p01_a; p11_a = ri.m_affine * p11_a; PerspectiveDistorter perpDistorter( p00_b - inTile.m_pos, p10_b - inTile.m_pos, p01_b - inTile.m_pos, p11_b - inTile.m_pos, p00_a, p10_a, p01_a, p11_a); BilinearDistorter bilDistorter( p00_b - inTile.m_pos, p10_b - inTile.m_pos, p01_b - inTile.m_pos, p11_b - inTile.m_pos, p00_a, p10_a, p01_a, p11_a); TQuadDistorter *distorter; if (m_distortType->getValue() == PERSPECTIVE) distorter = &perpDistorter; else if (m_distortType->getValue() == BILINEAR) distorter = &bilDistorter; else assert(0); if (m_isCastShadow) { TRaster32P ras32 = inTile.getRaster(); TRaster64P ras64 = inTile.getRaster(); if (ras32) { if (m_fade->getValue(frame) > 0) doFade(ras32, m_color->getValue(frame), m_fade->getValue(frame) / 100.0); if (brad > 0) doBlur(ras32, upBlur, downBlur, m_upTransp->getValue(frame) / 100.0, m_downTransp->getValue(frame) / 100.0, inBBox.y0 - inTile.m_pos.y, inBBox.y1 - inTile.m_pos.y); else if (m_upTransp->getValue(frame) > 0 || m_downTransp->getValue(frame) > 0) doTransparency(ras32, m_upTransp->getValue(frame) / 100.0, m_downTransp->getValue(frame) / 100.0, inBBox.y0 - inTile.m_pos.y, inBBox.y1 - inTile.m_pos.y); } else if (ras64) { if (m_fade->getValue(frame) > 0) doFade(ras64, toPixel64(m_color->getValue(frame)), m_fade->getValue(frame) / 100.0); if (brad > 0) doBlur(ras64, upBlur, downBlur, m_upTransp->getValue(frame) / 100.0, m_downTransp->getValue(frame) / 100.0, inBBox.y0 - inTile.m_pos.y, inBBox.y1 - inTile.m_pos.y); else if (m_upTransp->getValue(frame) > 0 || m_downTransp->getValue(frame) > 0) doTransparency(ras64, m_upTransp->getValue(frame) / 100.0, m_downTransp->getValue(frame) / 100.0, inBBox.y0 - inTile.m_pos.y, inBBox.y1 - inTile.m_pos.y); } else assert(false); } distort(tileRas, inTile.getRaster(), *distorter, convert(tile.m_pos), TRop::Bilinear); }