Giter Site home page Giter Site logo

Comments (6)

jxt1234 avatar jxt1234 commented on June 14, 2024

这个看着是 dest 为空,检查下 convert 的目标指针是否为空吧

from mnn.

feixuedudiao avatar feixuedudiao commented on June 14, 2024

图片
目标指针已经有判空。

from mnn.

feixuedudiao avatar feixuedudiao commented on June 14, 2024

图片

from mnn.

feixuedudiao avatar feixuedudiao commented on June 14, 2024

已经对dest指针做判空处理,但还是出现。
if(NULL == kv.second)
return NCE_FAILED;

        MNN::Tensor *pTensor = kv.second;
        NCE_S32 pWidth = pTensor->width();
        NCE_S32 pHeight = pTensor->height();
        NCE_S32 pChn    = pTensor->channel();
        NCE_S32 imgSz = pWidth * pHeight;
        NCE_U8 * data = (NCE_U8*)pTensor->host<void>();

        if (data == NULL)
        {
            return NCE_FAILED;
        }
     ...

pprocessors->convert(image_datas.image,
image_datas.image_attr.u32Width,
image_datas[count].image_attr.u32Height,
0,
kv.second);

from mnn.

feixuedudiao avatar feixuedudiao commented on June 14, 2024

ErrorCode CPUImageProcess::onExecute(const std::vector<Tensor > &inputs, const std::vector<Tensor > &outputs) {
if (0 == mStride) {
mStride = iw * ic;
}
auto source = inputs[0]->host<uint8_t>();
void
dest = nullptr;
CV::Point points[2];
auto destBytes = dtype.bytes();
int tileCount = UP_DIV(ow, CACHE_SIZE);
const int
regions = nullptr;
if (draw) {
// change input to output
dest = source;
oh = inputs[1]->length(0);
ow = iw;
oc = ic;
destBytes = inputs[0]->getType().bytes();
// draw one
tileCount = 1;
// src is color
samplerDest = inputs[2]->host<uint8_t>();
// get region info ptr
regions = inputs[1]->host();
} else {
dest = outputs[0]->host();
}

if (nullptr == dest)
    return INPUT_DATA_ERROR;

for (int i = 0; i < oh; ++i) {
    int dy = draw ? regions[3 * i] : i;
    auto dstY = (uint8_t*)dest + dy * destBytes * ow * oc;
    for (int tIndex = 0; tIndex < tileCount; ++tIndex) {
        int xStart    = tIndex * CACHE_SIZE;
        int count     = std::min(CACHE_SIZE, ow - xStart);
        if (draw) {
            xStart = regions[3 * i + 1];
            count = regions[3 * i + 2] - xStart + 1;
        }
        auto dstStart = dstY + destBytes * oc * xStart;

        if (!blitFloat) {
            blitDest = dstStart;
        }
        if (!blitter) {
            samplerDest = blitDest;
        }

        // Sample
        if (!draw) {
            // Compute position
            points[0].fX = xStart;
            points[0].fY = dy;

            points[1].fX = xStart + count;
            points[1].fY = dy;
            transform.mapPoints(points, 2);
            float deltaY = points[1].fY - points[0].fY;
            float deltaX = points[1].fX - points[0].fX;

            int sta = 0;
            int end = count;

            // FUNC_PRINT(sta);
            if (wrap == WrapType_ZERO) {
                // Clip: Cohen-Sutherland
                auto clip    = _computeClip(points, iw, ih, transformInvert, xStart, count);
                sta          = clip.first;
                end          = clip.second;
                points[0].fX = sta + xStart;
                points[0].fY = dy;

                transform.mapPoints(points, 1);
                if (sta != 0 || end < count) {
                    if (ic > 0) {
                        if (sta > 0) {
                            ::memset(samplerDest, paddingValue, ic * sta);
                        }
                        if (end < count) {
                            ::memset(samplerDest + end * ic, paddingValue, (count - end) * ic);
                        }
                    } else {
                        // TODO, Only support NV12 / NV21
                        ::memset(samplerDest, paddingValue, count);
                        ::memset(samplerDest + count, 128, UP_DIV(count, 2) * 2);
                    }
                }
            }
            points[1].fX = (deltaX) / (float)(count);
            points[1].fY = (deltaY) / (float)(count);

            sampler(source, samplerDest, points, sta, end - sta, count, iw, ih, mStride);
        }
        // Convert format
        if (blitter) {
            blitter(samplerDest, blitDest, count);
        }
        // Turn float
        if (blitFloat) {
            blitFloat(blitDest, (float*)dstStart, mean, normal, count);

上面是onExecute函数的代码,函数void MNNC3ToFloatRGBA(const unsigned char* source, float* dest, const float* mean, const float* normal, size_t count)中的dest指针是通过for循环遍历指针指代进行的,如果在convert中的dest为空,这在onExecute函数中就出现异常了。

from mnn.

github-actions avatar github-actions commented on June 14, 2024

Marking as stale. No activity in 60 days.

from mnn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.