放大功能 - 安卓R

Android 12 应用兼容性适配指导 Android 12 应用兼容性适配指导 一、兼容性调试工具 Android 11开始引入了新的工具,可针对Android新平台中的行为变更进行测试和调试。这些工具是兼容性框架的一部分,该框架使得开发者可通过开发者选项或adb命令单独打开和关闭各项变更。藉此,可在最新android预览版中测试我们的app受到新平台及target api调整的影响,完成app对新平台的兼容适配。 使用adb命令打开或关闭变更,请运行以下命令之一: adb shell am compat enable (C.. 阅读详情

放大功能简介

在手机设置 → 更多设置 → 无障碍 → 视觉 → 放大功能里面可以开启放大功能。这个功能可以把屏幕放大,放大屏幕后可以拖动屏幕位置。

可以放大的窗口:app、状态栏等

不能放大的窗口:导航栏、输入法、圆角等

放大功能实现

响应输入准备放大

从frameworks/base/services/accessibility/java/com/android/server/accessibility/FullScreenMagnificationGestureHandler.java的内部类DetectingState的onTripleTap方法开始:

        private void onTripleTap(MotionEvent up) {
            if (DEBUG_DETECTING) {
                Slog.i(LOG_TAG, "onTripleTap(); delayed: "
                        + MotionEventInfo.toString(mDelayedEventQueue));
            }
            clear();

            // Toggle zoom
            if (mMagnificationController.isMagnifying(mDisplayId)) {
                zoomOff();
            } else {
                zoomOn(up.getX(), up.getY());
            }
        }

调用了FullScreenMagnificationGestureHandler的zoomOn方法:

    private void zoomOn(float centerX, float centerY) {
        if (DEBUG_DETECTING) Slog.i(LOG_TAG, "zoomOn(" + centerX + ", " + centerY + ")");

        final float scale = MathUtils.constrain(
                mMagnificationController.getPersistedScale(),
                MIN_SCALE, MAX_SCALE);
        mMagnificationController.setScaleAndCenter(mDisplayId,
                scale, centerX, centerY,
                /* animate */ true,
                AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);
    }

调用了frameworks/base/services/accessibility/java/com/android/server/accessibility/MagnificationController.java的setScaleAndCenter方法:

    /**
     * Sets the scale and center of the magnified region, optionally
     * animating the transition. If animation is disabled, the transition
     * is immediate.
     *
     * @param displayId The logical display id.
     * @param scale the target scale, or {@link Float#NaN} to leave unchanged
     * @param centerX the screen-relative X coordinate around which to
     *                center and scale, or {@link Float#NaN} to leave unchanged
     * @param centerY the screen-relative Y coordinate around which to
     *                center and scale, or {@link Float#NaN} to leave unchanged
     * @param animate {@code true} to animate the transition, {@code false}
     *                to transition immediately
     * @param id the ID of the service requesting the change
     * @return {@code true} if the magnification spec changed, {@code false} if
     *         the spec did not change
     */
    public boolean setScaleAndCenter(int displayId, float scale, float centerX, float centerY,
            boolean animate, int id) {
        synchronized (mLock) {
            final DisplayMagnification display = mDisplays.get(displayId);
            if (display == null) {
                return false;
            }
            return display.setScaleAndCenter(scale, centerX, centerY, animate, id);
        }
    }

调用了MagnificationController内部类DisplayMagnification的setScaleAndCenter方法:

        @GuardedBy("mLock")
        boolean setScaleAndCenter(float scale, float centerX, float centerY,
                boolean animate, int id) {
            if (!mRegistered) {
                return false;
            }
            if (DEBUG) {
                Slog.i(LOG_TAG,
                        "setScaleAndCenterLocked(scale = " + scale + ", centerX = " + centerX
                                + ", centerY = " + centerY + ", animate = " + animate
                                + ", id = " + id
                                + ")");
            }
            final boolean changed = updateMagnificationSpecLocked(scale, centerX, centerY);
            sendSpecToAnimation(mCurrentMagnificationSpec, animate);
            if (isMagnifying() && (id != INVALID_ID)) {
                mIdOfLastServiceToMagnify = id;
            }
            return changed;
        }

调用了MagnificationController内部类DisplayMagnification的updateMagnificationSpecLocked方法:

        /**
         * Updates the current magnification spec.
         *
         * @param scale the magnification scale
         * @param centerX the unscaled, screen-relative X coordinate of the center
         *                of the viewport, or {@link Float#NaN} to leave unchanged
         * @param centerY the unscaled, screen-relative Y coordinate of the center
         *                of the viewport, or {@link Float#NaN} to leave unchanged
         * @return {@code true} if the magnification spec changed or {@code false}
         *         otherwise
         */
        boolean updateMagnificationSpecLocked(float scale, float centerX, float centerY) {
            // Handle defaults.
            if (Float.isNaN(centerX)) {
                centerX = getCenterX();
            }
            if (Float.isNaN(centerY)) {
                centerY = getCenterY();
            }
            if (Float.isNaN(scale)) {
                scale = getScale();
            }

            // Compute changes.
            boolean changed = false;

            final float normScale = MathUtils.constrain(scale, MIN_SCALE, MAX_SCALE);
            if (Float.compare(mCurrentMagnificationSpec.scale, normScale) != 0) {
                mCurrentMagnificationSpec.scale = normScale;
                changed = true;
            }

            final float nonNormOffsetX = mMagnificationBounds.width() / 2.0f
                    + mMagnificationBounds.left - centerX * normScale;
            final float nonNormOffsetY = mMagnificationBounds.height() / 2.0f
                    + mMagnificationBounds.top - centerY * normScale;
            changed |= updateCurrentSpecWithOffsetsLocked(nonNormOffsetX, nonNormOffsetY);

            if (changed) {
                onMagnificationChangedLocked();
            }

            return changed;
        }

放大窗口

回到MagnificationController内部类DisplayMagnification的setScaleAndCenter方法中,后面还调用了MagnificationController内部类DisplayMagnification的sendSpecToAnimation方法:

        void sendSpecToAnimation(MagnificationSpec spec, boolean animate) {
            if (DEBUG) {
                Slog.i(LOG_TAG,
                        "sendSpecToAnimation(spec = " + spec + ", animate = " + animate + ")");
            }
            if (Thread.currentThread().getId() == mMainThreadId) {
                mSpecAnimationBridge.updateSentSpecMainThread(spec, animate);
            } else {
                final Message m = PooledLambda.obtainMessage(
                        SpecAnimationBridge::updateSentSpecMainThread,
                        mSpecAnimationBridge, spec, animate);
                mControllerCtx.getHandler().sendMessage(m);
            }
        }

调用了MagnificationController的内部类SpecAnimationBridge的updateSentSpecMainThread方法:

        public void updateSentSpecMainThread(MagnificationSpec spec, boolean animate) {
            if (mValueAnimator.isRunning()) {
                mValueAnimator.cancel();
            }

            // If the current and sent specs don't match, update the sent spec.
            synchronized (mLock) {
                final boolean changed = !mSentMagnificationSpec.equals(spec);
                if (changed) {
                    if (animate) {
                        animateMagnificationSpecLocked(spec);
                    } else {
                        setMagnificationSpecLocked(spec);
                    }
                }
            }
        }

这里animate传过来的是true,因此调用了MagnificationController的内部类SpecAnimationBridge的animateMagnificationSpecLocked方法:

        private void animateMagnificationSpecLocked(MagnificationSpec toSpec) {
            mEndMagnificationSpec.setTo(toSpec);
            mStartMagnificationSpec.setTo(mSentMagnificationSpec);
            mValueAnimator.start();
        }

MagnificationController的内部类SpecAnimationBridge本身实现了ValueAnimator.AnimatorUpdateListener接口,这里的mValueAnimator在开始执行动画后,每帧都会调用MagnificationController的内部类SpecAnimationBridge的onAnimationUpdate方法:

    /**
     * Class responsible for animating spec on the main thread and sending spec
     * updates to the window manager.
     */
    private static class SpecAnimationBridge implements ValueAnimator.AnimatorUpdateListener {
        ......
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            synchronized (mLock) {
                if (mEnabled) {
                    float fract = animation.getAnimatedFraction();
                    mTmpMagnificationSpec.scale = mStartMagnificationSpec.scale +
                            (mEndMagnificationSpec.scale - mStartMagnificationSpec.scale) * fract;
                    mTmpMagnificationSpec.offsetX = mStartMagnificationSpec.offsetX +
                            (mEndMagnificationSpec.offsetX - mStartMagnificationSpec.offsetX)
                                    * fract;
                    mTmpMagnificationSpec.offsetY = mStartMagnificationSpec.offsetY +
                            (mEndMagnificationSpec.offsetY - mStartMagnificationSpec.offsetY)
                                    * fract;
                    setMagnificationSpecLocked(mTmpMagnificationSpec);
                }
            }
        }
    }

将动画当前的scale、offsetX、offsetY计算出来保存到mTmpMagnificationSpec中,然后调用了MagnificationController的内部类SpecAnimationBridge的setMagnificationSpecLocked方法:

        @GuardedBy("mLock")
        private void setMagnificationSpecLocked(MagnificationSpec spec) {
            if (mEnabled) {
                if (DEBUG_SET_MAGNIFICATION_SPEC) {
                    Slog.i(LOG_TAG, "Sending: " + spec);
                }

                mSentMagnificationSpec.setTo(spec);
                mControllerCtx.getWindowManager().setMagnificationSpec(
                        mDisplayId, mSentMagnificationSpec);
            }
        }

调用了frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java的内部类LocalService的setMagnificationSpec方法:

        @Override
        public void setMagnificationSpec(int displayId, MagnificationSpec spec) {
            synchronized (mGlobalLock) {
                if (mAccessibilityController != null) {
                    mAccessibilityController.setMagnificationSpecLocked(displayId, spec);
                } else {
                    throw new IllegalStateException("Magnification callbacks not set!");
                }
            }
            if (Binder.getCallingPid() != myPid()) {
                spec.recycle();
            }
        }

调用了frameworks/base/services/core/java/com/android/server/wm/AccessibilityController.java的setMagnificationSpecLocked方法:

    public void setMagnificationSpecLocked(int displayId, MagnificationSpec spec) {
        final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId);
        if (displayMagnifier != null) {
            displayMagnifier.setMagnificationSpecLocked(spec);
        }
        final WindowsForAccessibilityObserver windowsForA11yObserver =
                mWindowsForAccessibilityObserver.get(displayId);
        if (windowsForA11yObserver != null) {
            windowsForA11yObserver.scheduleComputeChangedWindowsLocked();
        }
    }

调用了AccessibilityController的内部静态类DisplayMagnifier的setMagnificationSpecLocked方法:

        public void setMagnificationSpecLocked(MagnificationSpec spec) {
            mMagnifedViewport.updateMagnificationSpecLocked(spec);
            mMagnifedViewport.recomputeBoundsLocked();

            mService.applyMagnificationSpecLocked(mDisplay.getDisplayId(), spec);
            mService.scheduleAnimationLocked();
        }

调用了WindowManagerService的applyMagnificationSpecLocked方法

    /** Called from Accessibility Controller to apply magnification spec */
    public void applyMagnificationSpecLocked(int displayId, MagnificationSpec spec) {
        final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
        if (displayContent != null) {
            displayContent.applyMagnificationSpec(spec);
        }
    }

调用了frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java的applyMagnificationSpec方法:

    void applyMagnificationSpec(MagnificationSpec spec) {
        if (spec.scale != 1.0) {
            mMagnificationSpec = spec;
        } else {
            mMagnificationSpec = null;
        }
        // Re-parent IME's SurfaceControl when MagnificationSpec changed.
        updateImeParent();

        if (spec.scale != 1.0) {
            applyMagnificationSpec(getPendingTransaction(), spec);
        } else {
            clearMagnificationSpec(getPendingTransaction());
        }
        getPendingTransaction().apply();
    }

调用了frameworks/base/services/core/java/com/android/server/wm/WindowContainer.java的applyMagnificationSpec方法:

    // TODO(b/68336570): Should this really be on WindowContainer since it
    // can only be used on the top-level nodes that aren't animated?
    // (otherwise we would be fighting other callers of setMatrix).
    void applyMagnificationSpec(Transaction t, MagnificationSpec spec) {
        if (shouldMagnify()) {
            t.setMatrix(mSurfaceControl, spec.scale, 0, 0, spec.scale)
                    .setPosition(mSurfaceControl, spec.offsetX, spec.offsetY);
            mLastMagnificationSpec = spec;
        } else {
            clearMagnificationSpec(t);
            for (int i = 0; i < mChildren.size(); i++) {
                mChildren.get(i).applyMagnificationSpec(t, spec);
            }
        }
    }

这里首先调用了WindowContainer的shouldMagnify方法判断当前窗口是否需要放大,如果需要则调用frameworks/base/core/java/android/view/SurfaceControl.java的内部静态类Transaction的setMatrix方法和setPosition方法执行放大,如果不需要则依次调用子节点窗口的applyMagnificationSpec方法。

确定哪些窗口需要放大

接下来看下是如何确定哪些窗口需要放大的,看WindowContainer的shouldMagnify方法:

    /**
     * @return Whether this WindowContainer should be magnified by the accessibility magnifier.
     */
    boolean shouldMagnify() {
        if (mSurfaceControl == null) {
            return false;
        }

        for (int i = 0; i < mChildren.size(); i++) {
            if (!mChildren.get(i).shouldMagnify()) {
                return false;
            }
        }
        return true;
    }

依次调用所有子节点的shouldMagnify方法来判断是否需要放大。

如果是frameworks/base/services/core/java/com/android/server/wm/WindowState.java,其shouldMagnify方法:

    @Override
    boolean shouldMagnify() {
        if (mAttrs.type == TYPE_INPUT_METHOD ||
                mAttrs.type == TYPE_INPUT_METHOD_DIALOG ||
                mAttrs.type == TYPE_MAGNIFICATION_OVERLAY ||
                mAttrs.type == TYPE_NAVIGATION_BAR ||
                // It's tempting to wonder: Have we forgotten the rounded corners overlay?
                // worry not: it's a fake TYPE_NAVIGATION_BAR_PANEL
                mAttrs.type == TYPE_NAVIGATION_BAR_PANEL) {
            return false;
        }
        return true;
    }

根据窗口类型判断是否需要放大,如果窗口类型是TYPE_INPUT_METHOD、TYPE_INPUT_METHOD_DIALOG、TYPE_MAGNIFICATION_OVERLAY、TYPE_NAVIGATION_BAR或TYPE_NAVIGATION_BAR_PANEL则不放大。

如果是DisplayContent的内部类NonAppWindowContainers,其shouldMagnify方法:

        @Override
        boolean shouldMagnify() {
            // Omitted from Screen-Magnification
            return false;
        }

直接返回false,说明NonAppWindowContainers不需要放大。

放大区域边界的显示

从frameworks/base/services/core/java/com/android/server/wm/WindowAnimator.java的animate方法开始:

    private void animate(long frameTimeNs) {
        if (!mInitialized) {
            return;
        }

        // Schedule next frame already such that back-pressure happens continuously.
        scheduleAnimation();

        mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
        mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
        if (DEBUG_WINDOW_TRACE) {
            Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime);
        }

        ProtoLog.i(WM_SHOW_TRANSACTIONS, ">>> OPEN TRANSACTION animate");
        mService.openSurfaceTransaction();
        try {
            final AccessibilityController accessibilityController =
                    mService.mAccessibilityController;
            final int numDisplays = mDisplayContentsAnimators.size();
            for (int i = 0; i < numDisplays; i++) {
                final int displayId = mDisplayContentsAnimators.keyAt(i);
                final DisplayContent dc = mService.mRoot.getDisplayContent(displayId);
                // Update animations of all applications, including those associated with
                // exiting/removed apps.
                dc.updateWindowsForAnimator();
                dc.prepareSurfaces();
            }

            for (int i = 0; i < numDisplays; i++) {
                final int displayId = mDisplayContentsAnimators.keyAt(i);
                final DisplayContent dc = mService.mRoot.getDisplayContent(displayId);

                dc.checkAppWindowsReadyToShow();
                if (accessibilityController != null) {
                    accessibilityController.drawMagnifiedRegionBorderIfNeededLocked(displayId,
                            mTransaction);
                }
            }

            cancelAnimation();

            if (mService.mWatermark != null) {
                mService.mWatermark.drawIfNeeded();
            }

        } catch (RuntimeException e) {
            Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
        }
        ......
    }

调用了AccessibilityController的drawMagnifiedRegionBorderIfNeededLocked方法:

    public void drawMagnifiedRegionBorderIfNeededLocked(int displayId,
            SurfaceControl.Transaction t) {
        final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId);
        if (displayMagnifier != null) {
            displayMagnifier.drawMagnifiedRegionBorderIfNeededLocked(t);
        }
        // Not relevant for the window observer.
    }

调用了AccessibilityController的内部类DisplayMagnifier的drawMagnifiedRegionBorderIfNeededLocked方法:

        public void drawMagnifiedRegionBorderIfNeededLocked(SurfaceControl.Transaction t) {
            mMagnifedViewport.drawWindowIfNeededLocked(t);
        }

调用了AccessibilityController的内部静态类DisplayMagnifier的内部类MagnifiedViewport的drawWindowIfNeededLocked方法:

            public void drawWindowIfNeededLocked(SurfaceControl.Transaction t) {
                recomputeBoundsLocked();
                mWindow.drawIfNeeded(t);
            }

调用了AccessibilityController的内部静态类DisplayMagnifier的内部类MagnifiedViewport的内部类ViewportWindow的drawIfNeeded方法:

                public void drawIfNeeded(SurfaceControl.Transaction t) {
                    synchronized (mService.mGlobalLock) {
                        if (!mInvalidated) {
                            return;
                        }
                        mInvalidated = false;
                        if (mAlpha > 0) {
                            Canvas canvas = null;
                            try {
                                // Empty dirty rectangle means unspecified.
                                if (mDirtyRect.isEmpty()) {
                                    mBounds.getBounds(mDirtyRect);
                                }
                                mDirtyRect.inset(-mHalfBorderWidth, -mHalfBorderWidth);
                                canvas = mSurface.lockCanvas(mDirtyRect);
                                if (DEBUG_VIEWPORT_WINDOW) {
                                    Slog.i(LOG_TAG, "Dirty rect: " + mDirtyRect);
                                }
                            } catch (IllegalArgumentException iae) {
                                /* ignore */
                            } catch (Surface.OutOfResourcesException oore) {
                                /* ignore */
                            }
                            if (canvas == null) {
                                return;
                            }
                            if (DEBUG_VIEWPORT_WINDOW) {
                                Slog.i(LOG_TAG, "Bounds: " + mBounds);
                            }
                            canvas.drawColor(Color.TRANSPARENT, Mode.CLEAR);
                            mPaint.setAlpha(mAlpha);
                            Path path = mBounds.getBoundaryPath();
                            canvas.drawPath(path, mPaint);

                            mSurface.unlockCanvasAndPost(canvas);
                            t.show(mSurfaceControl);
                        } else {
                            t.hide(mSurfaceControl);
                        }
                    }
                }
Android系统冻屏、黑屏问题的分析思路 是新加的方法,需要在Layer也加上相应的实现,如下。》可以指导,应用的图形内容要经过SurfaceFlinger才能传递到显示设备,SurfaceFlinger每隔一定时间(间隔由帧率决定)会向屏幕传递图形数据,但是并不是每个应用的图形都会显示,只有最前面应用的画面才能显示,应用的图形数据一般保存在图层中,因此每次刷新都会收集可见的图层。在Android系统开发过程中,偶尔会遇到显示异常的问题,如画面不再刷新,也就是冻屏,或者屏幕变黑,如果对图形显示系统不熟悉,遇到此类问题还是比较棘手的。 阅读详情

相关推荐

Android 高仿微信朋友圈动态, 支持双击手势放大并滑动查看图片。

实现朋友圈动态功能,支持动态加载图片,双击放大,手势缩放,滑动查看功能。

Tamic (大白) 9381

Android 窗口常见参数汇总

Window类中有一个WindowManager.LayoutParams类型的属性mWindowAttributes记录了当前窗口的相关参数

yimelancholy的博客 5270

android tv gridview焦点放大效果

android tv gridview焦点放大效果

zhouguizhi 1万+

Android窗口类型

WindowManager会根据窗口的类型来决定Z-Order,通过Z-Order也就决定了窗口从上到下的显示顺序。下表个表明了窗口类型与Z-Order的关系。表中layer值越大表示窗口越靠上。

leopard21的专栏 4397

Android 11.0 自定义仿小米全面屏手势导航左右手势滑动返回UI效果

在定制化开发中,对SystemUI的UI效果修改定制也是常有的功能,由于发现小米全面屏手势左右滑动返回UI效果比较美观 所以有需求要求仿小米全面屏手势来做左右滑动返回UI的效果,来自定义UI做手势返回的布局样式,这样的弧线就涉及到用贝塞尔曲线来实现功能...

安卓兼职framework和app工程师的博客 3137

Android实现放大镜功能

通过为需要放大的视图设置触摸事件监听器,并根据触摸位置更新放大镜的位置和内容,我们可以实现一个简单但有效的放大镜功能。最后,我们需要更新放大镜的内容,即根据触摸位置在原始图像上截取对应区域的部分作为放大镜的显示内容。接下来,我们需要在相应的Activity中实现放大镜的逻辑。在上述代码中,我们根据触摸事件的位置计算放大镜容器的左上角坐标,并更新容器的布局参数。事件中,我们更新放大镜视图的位置和内容,并设置放大镜容器的可见性为。对象,作为放大镜的显示内容,并将其设置为放大镜视图的图像。在上述代码中,我们为。

CyberBladeX的博客 575

kafka不使用自带zk_手机居然自带"放大镜"功能?人人能使用到,可惜很多人不知道...

手机居然自带"放大镜"功能?人人能使用到,可惜很多人不知道放大镜是我们常人不怎么需要的一键物品,却被手机厂商们加入到了手机的功能里,现在的多数手机都自带"放大镜"功能,其实手机厂商最早只是为了让老人方便识别屏幕上的文字而设计的方法功能,奈何手机的拍照功能越来越强大,所以被不少用户当作"望远镜"来用。那么我们如何使用这个手机自带的"放大镜"功能呢?1、 安卓机调试因为安卓机的种类众多,小酱以自己的O...

weixin_35928736的博客 213

IBTrACS v04r01 数据提取实战:Pandas 筛选 JTWC/CMA/JMA 3机构最佳路径数据

本文详细介绍了如何使用 Pandas 高效提取和处理 IBTrACS v04r01 数据集中的最佳路径数据,特别针对 JTWC、CMA 和 JMA 三家权威机构的数据进行对比分析。通过构建可复用的数据提取函数,解决多机构数据质量差异问题,并提供高级分析与可视化应用示例,助力热带气旋研究。

clijovtbq401783153的博客 518

android 放大镜功能,利用Android实现一个放大镜功能

利用Android实现一个放大镜功能发布时间:2020-11-20 16:48:19来源:亿速云阅读:104作者:Leah今天就跟大家聊聊有关利用Android实现一个放大镜功能,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。源码分析public class ShaderView extends View {private final Bit...

weixin_29442503的博客 1045

保姆级教程:手把手教你用CANoe/CANalyzer读取汽车故障码(UDS 0x19服务实战)

本文提供了一份详细的CANoe/CANalyzer使用教程,指导如何通过UDS 0x19服务读取汽车故障码。从硬件配置到报文构建,再到故障码解析,手把手教你完成汽车诊断全流程,特别适合汽车电子工程师和诊断开发人员。

weixin_42524945的博客 265

目标检测数据集 第069期-基于yolo标注格式的玻璃清洁状态检测数据集(含免费分享)

但这类技术的落地,离不开大量标注规范、场景丰富的数据集作为算法训练的支撑,玻璃清洁状态检测数据集的出现,正是为了满足这一市场与技术需求。在高校与科研机构的计算机视觉研究中,该数据集可作为基础研究素材,用于探索物体状态识别的算法优化方向,比如针对玻璃这类透明物体的检测算法改进,或是小样本场景下的状态识别研究。通过摄像头采集车窗、挡风玻璃的图像,算法自动检测玻璃清洁度,若识别到脏污影响视线,及时提醒运维人员清洁,避免因玻璃脏污引发的安全事故,提升交通出行的安全性。

深度学习算法工程师,专注于前沿算法研究与实战应用。在这里,我将分享深度学习领域的实战经验、优质数据集资源以及最新论文解读与精度分析,旨在与广大技术爱好者共同探索人工智能的奥秘,助力技术成长与创新。 130

android 放大镜功能,简单实现Android放大镜效果

利用之前学过的图形图像绘画技术和图片添加特效技术,我们来实现一个Android放大镜的简单应用。最终效果如图具体实现:用来显示自定义的绘图类的布局文件res/layout/main.xml:xmlns:tools="http://schemas.android.com/tools"android:layout_width="fill_parent"android:layout_height="fi...

weixin_35212109的博客 1569

SAP PS项目结算实操:从CJ20N到CJ88,手把手搞定项目成本结转与凭证生成

本文详细解析SAP PS项目结算全流程,从CJ20N到CJ88的操作要点,涵盖成本归集、结算规则配置、结果分析及凭证生成等关键环节。特别针对FICO模块中的项目凭证流转问题提供实战解决方案,帮助财务人员规避常见配置错误,提升项目结算效率与准确性。

weixin_26833503的博客 824

android 放大镜功能,Android放大镜效果实现

概述我相信很多用过英语应用的同学都看多一个放大镜的效果,就是选中一段文字后,会有一个放大镜,这个究竟怎么实现的呢,我们今天来分析分析。源码分析publicclassShaderViewextendsView{privatefinalBitmapbitmap;privatefinalShapeDrawabledrawable;//放大镜的半径privatestaticfi...

weixin_33678821的博客 738

HyperMesh二次开发实战:自动化Comp与材料属性批量绑定

本文详细介绍了HyperMesh二次开发中自动化Comp与材料属性批量绑定的实战技巧。通过TCL脚本实现批量创建属性卡、智能材料分配和异常处理,大幅提升前处理效率,适用于汽车、航空航天等领域的复杂模型处理。

weixin_29214691的博客 695

视图库对接系列(GA-T 1400)一、简单介绍

GA/T 1400《公安视频图像信息应用系统》 是我们需要参考看看的相关文档,里面有对应的标准和介绍,没有这个文档的话可以加群找我要。群的话 我放在最下面了。我们先简单想几个问题, 也就是这个协议主要干什么用的,为什么要有, 能做什么。

qq_37716298的博客 4301

Android 放大镜

之前做过iOS下的放大镜功能,这个再来一个Android版的。 ShaderView.java package com.pactera.magnifierdemo; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import an

杜甲同学的专栏 2727

强化学习从基础到进阶-常见问题和面试必知必答[7]:深度确定性策略梯度DDPG算法、双延迟深度确定性策略梯度TD3算法详解

强化学习从基础到进阶-常见问题和面试必知必答[7]:深度确定性策略梯度DDPG算法、双延迟深度确定性策略梯度TD3算法详解

丨汀、的博客 514

Android播放器实现视频窗口实时放大缩小功能

很多开发者希望Android播放端实现视频窗口的放大缩小功能,为此,我们做了个简单的demo,通过播放端回调RGB数据,直接在上层view操作处理即可,Github:https://github.com/daniulive/SmarterStreaming 无视频无真相:http://www.iqiyi.com/w_19s9sa7epp.html 基本流程如下: 1. 基础的初始化和参数设定...

大牛直播SDK 4674

Python爬虫实战:利用最新技术爬取抖音话题挑战视频

本文将详细介绍如何使用Python最新技术栈构建一个高效的抖音话题挑战视频爬虫。我们将从环境配置开始,逐步讲解请求模拟、数据解析、反反爬策略、数据存储等关键环节,并提供完整的代码实现。本文适合有一定Python基础的开发者学习高级网络爬虫技术。关键词:Python爬虫、抖音API、话题挑战、视频爬取、反反爬本文详细介绍了如何使用Python最新技术栈构建抖音话题挑战视频爬虫。我们从基础请求开始,逐步实现了数据解析、反反爬策略、数据存储等核心功能,并探讨了分布式和增量爬取等高级主题。更智能的反反爬策略。

2201_76125261的博客 1747

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Android中的神器-放大镜

文章目录一、前言二、放大镜的使用2.1 API调用2.2 在用户交互中使用放大镜三、观后语 一、前言 在Android 9(API level 28)及以上版本,支持放大镜功能,这个功能可以提高文本插入、选择的用户体验,可供用户看清细小的文字,例如:地图上的地名。放大镜功能在系统控件,例如:TextView、EditText、WebView中已经集成。效果如下图: 不过可惜的是,放大镜功能只能...

yingaizhu的博客 4801

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

android 阅读器放大镜,制作安卓PDF阅读器:四、实现文本选择之放大镜、长按拖动...

看到一篇知乎上的文章,《这可能是最好用的一款 PDF 阅读、批注工具~如果他称第二,没人敢称第一!》,看了后下载试用,还好。单就触屏体验而言,没他说的那么好听。这类国产APP的门面都是非常好看的,不论是图标还是动画效果。比如 ( 轻快PDF阅读器 ):漂亮的图标,给画家点赞!再如( PDF Viewer - com.pspdfkit.viewer ):竟然连小图标都有渐变效果,膜拜!菜单的弹出...

weixin_31586521的博客 857

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Android 实现放大镜功能源码

Android 实现放大镜功能 需用到Bitmap、BitmapShader、Matrix、Canvas、BitmapFactory等Android的类。 如下是源码: package com.lulu; import android.app.Activity; import android.content.Context; import android.graphics.Bit

ludeyao的博客 2040

安卓应用层抓包通杀脚本r0capture

仅限安卓平台,测试安卓7、8、9、10、11 可用;无视所有证书校验或绑定,不用考虑任何证书的事情;通杀TCP/IP四层模型中的应用层中的全部协议;通杀协议包括:Http,WebSocket,Ftp,Xmpp,Imap,Smtp,Protobuf等等、以及它们的SSL版本;通杀所有应用层框架,包括HttpUrlConnection、Okhttp1/3/4、Retrofit/Volley等等;无视加固,不管是整体壳还是二代壳或VMP,不用考虑加固的事情;

Codeooo 博客 1万+

android 图片手动放大,Android图片的手动放大缩小

利用缩放因子进行图片的放大缩小,效果图如下在实现过程中如出现直接崩溃的情况:在全局配置文件中加入android:largeHeap="true"即可解决问题,在文章最后有现成代码步骤:1.布局文件 android:scaleType="matrix"记得加上,不然没有效果2.控件实例化及处理机制的取代3.进行逻辑处理,并利用Matrix进行图片处理其中nowScale 及beforeScale为自...

weixin_32602727的博客 2855

Android 图片实现单击放大缩小

Android 图片实现单击放大缩小 记录使用 &lt;ImageView android:id="@+id/iv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" ...

qq_41577078的博客 2457
上一篇: 窗口布局流程 - 安卓R
下一篇: 拖拽分享 - 安卓R
SSSxCCC
博客等级 码龄10年 238粉丝 74原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SSSxCCC

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值