Ask Your Question

pouya.1991's profile - activity

2020-05-23 05:59:54 -0600 received badge  Notable Question (source)
2020-03-28 07:02:49 -0600 received badge  Popular Question (source)
2019-11-29 07:05:27 -0600 received badge  Popular Question (source)
2019-10-17 02:11:40 -0600 received badge  Notable Question (source)
2019-01-23 00:16:41 -0600 marked best answer How to run yolo 3 object detector on a NVidia GPU

Hi,

I've written a program which uses OpenCV (v 4.0.1) dnn module for object detection. Now I wanna to use my GPU (Geforce 1070) to accelerate my computation, but I found that at the moment OpenCV dnn module doesn't support Nvidia GPUs, so what is the best way to accelerate my program? I must use another framework like darknet to achieve this purpose or is there any other solution?

(I'm using Windows 10, CUDA 10 and CuDNN 7.4, MSVC 2017 64)

2019-01-21 15:56:28 -0600 edited question How to run yolo 3 object detector on a NVidia GPU

How to run yolo 3 object detector on NVidia GPU Hi, I've written a program which uses OpenCV (v 4.0.1) dnn module for

2019-01-21 15:43:50 -0600 asked a question How to run yolo 3 object detector on a NVidia GPU

How to run yolo 3 object detector on NVidia GPU Hi, I've written a program which uses OpenCV (v 4.0.1) dnn module for

2019-01-10 03:07:37 -0600 received badge  Popular Question (source)
2018-11-13 11:34:02 -0600 asked a question Opencv 4 h.264 decode delay

Opencv 4 h.264 decode delay Hi, I'm using OpenCV 4 (Compiled with MSVC 15-64bit + CUDA 10) and VideoCapture class to dec

2018-11-07 02:37:02 -0600 marked best answer Using two dnn networks causes crash

Hi I wanna to using two yolo networks in my program (an yolo3-tiny and an yolov3-spp), but when I call net.forward function for the second network, I'm got following exception :

terminate called after throwing an instance of 'cv::Exception'
what():  OpenCV(4.0.0-pre) /home/pouya/Develop/opecv4/opencv/modules/dnn/src/dnn.cpp:1149: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'getLayerData'

there is my code :

bool Detector::postprocesstiny(const std::vector<cv::Mat>& outs)
{

    for (size_t i = 0; i < outs.size(); ++i)
    {
        float* data = (float*)outs[i].data;
        for (int j = 0; j < outs[i].rows; ++j, data += outs[i].cols)
        {
            cv::Mat scores = outs[i].row(j).colRange(5, outs[i].cols);
            cv::Point classIdPoint;
            double confidence;
            minMaxLoc(scores, 0, &confidence, 0, &classIdPoint);

            if (classIdPoint.x==2 && confidence > 0.5)
                return true ;
        }

    }
    return false ;

}


std::vector<cv::String> Detector::getOutputsNames(const cv::dnn::Net& net)
{
    static std::vector<cv::String> names;
    if (names.empty())
    {
        std::vector<int> outLayers = net.getUnconnectedOutLayers();
        std::vector<cv::String> layersNames = net.getLayerNames();
        names.resize(outLayers.size());
        for (size_t i = 0; i < outLayers.size(); ++i)
            names[i] = layersNames[outLayers[i] - 1];
    }
    return names;
}


bool Detector::isThereAnyCar(cv::Mat image) {

cv::Mat inputBlob = cv::dnn::blobFromImage(image, 1 / 255.F , cv::Size(416, 416), cv::Scalar(), true, false); 
net_tiny.setInput(inputBlob);                 
std::vector<cv::Mat> outs;

net_tiny.forward(outs, getOutputsNames(net_tiny));  
return postprocesstiny(outs);

}

cv::dnn::Net net = cv::dnn::readNetFromDarknet(modelConfiguration, modelBinary);
cv::dnn::Net net_tiny = cv::dnn::readNetFromDarknet(modelConfigurationTiny, modelBinaryTiny);
cv::Mat frame;
cv::VideoCapture cap(source);
cap >> frame;
if (isThereAnyCar(frame)) {
        cv::Mat inputBlob = cv::dnn::blobFromImage(frame, 1 / 255.F , cv::Size(416, 416), cv::Scalar(), true, false); 
        net.setInput(inputBlob);                   
        std::vector<cv::Mat> outs;

        std::vector<DetectionResult> detection_results;
        net.forward(outs, getOutputsNames(net));  //This line causes error 

}

and when I comment one of the networks, it runs without any problem. Is there any solution for this problem?

2018-11-07 01:59:35 -0600 received badge  Self-Learner (source)
2018-11-07 01:59:07 -0600 received badge  Student (source)
2018-11-07 01:51:29 -0600 commented question Using two dnn networks causes crash

Both of them are v3, thank you I just omit if (names.empty()) in getOutputsNames and the error vanished :)

2018-11-07 01:26:53 -0600 commented question Using two dnn networks causes crash

thank you, just added :) the last line causes error but when I comment if (isThereAnyCar(frame)) or net.forward(outs, g

2018-11-07 01:24:22 -0600 edited question Using two dnn networks causes crash

Using two dnn networks causes crash Hi I wanna to using two yolo networks in my program (an yolo3-tiny and an yolov3-spp

2018-11-07 00:59:41 -0600 commented question Using two dnn networks causes crash

No I can run the ssp model without any problem, but when I want to run two networks to gather I get this error

2018-11-07 00:59:06 -0600 commented question Using two dnn networks causes crash

No I can run the ssp model without any problem, but when I want to run two networks to gather I got this error

2018-11-07 00:54:41 -0600 commented question Using two dnn networks causes crash

There is the configuration of this network : https://github.com/pjreddie/darknet/blob/master/cfg/yolov3-spp.cfg

2018-11-07 00:52:35 -0600 edited question Using two dnn networks causes crash

Using two dnn networks causes crash Hi I wanna to using two yolo networks in my program (an yolo3-tiny and an yolov3-spp

2018-11-07 00:51:08 -0600 edited question Using two dnn networks causes crash

Using two dnn network causes crash Hi I wanna to using two yolo network in my program (an yolo3-tiny and an yolov3-spp),

2018-11-07 00:49:38 -0600 edited question Using two dnn networks causes crash

Using two dnn network causes crash Hi I wanna to using two yolo network in my program (an yolo3-tiny and an yolov3-spp),

2018-11-07 00:49:24 -0600 edited question Using two dnn networks causes crash

Using two dnn network causes crash Hi I wanna to using two yolo network in my program (an yolo3-tiny and an yolov3-spp),

2018-11-07 00:47:03 -0600 asked a question Using two dnn networks causes crash

Using two dnn network causes crash Hi I wanna to using two yolo network in my program (a yolo3-tiny and a yolov3-spp), b

2018-11-07 00:36:58 -0600 marked best answer yolo dose not use my GPU

Hi there, I've installed CUDA 10 on ubuntu 18.04 and compiled both Opencv and darknet with cuda support successfully, but when I wanna to train a yolo network, darknet uses CPU to train the net, what I should do? Is there any other configuration for darknet to use GPU?

2018-11-06 04:05:24 -0600 commented question yolo dose not use my GPU

Hi thank you for your answers I didn't set GPU=1 in Makefile :X I set this flag and recompiled yolo and it uses gpu no

2018-11-05 21:55:29 -0600 asked a question yolo dose not use my GPU

yolo dose not use my GPU Hi there, I've installed CUDA 10 on ubuntu 18.04 and compiled both Opencv and darknet with cuda

2018-11-03 08:12:00 -0600 commented answer Opencv-4 compile error (MinGW 5.3 32)

I found that as you mentioned there is no CUDA support for mingw 32, so I'm gonna to use MSVC 64 instead :)

2018-11-02 07:41:43 -0600 commented answer Opencv-4 compile error (MinGW 5.3 32)

Thank you for feedback :) cheers

2018-11-02 04:47:10 -0600 commented answer Opencv-4 compile error (MinGW 5.3 32)

really ? :( I've developed a classification program in Qt, now for GPU supported I have to install visual studio and use

2018-11-02 04:34:38 -0600 marked best answer Opencv-4 compile error (MinGW 5.3 32)

Hi I just tried to compile latest opencv-4 version (beta) but I got following error :

[ 32%] Built target quirc
[ 32%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1c/sources/ade/source/alloc.cpp.obj
C:\Opencv\build\3rdparty\ade\ade-0.1.1c\sources\ade\source\alloc.cpp: In function 'void* ade::aligned_alloc(std::size_t, std::size_t)':
C:\Opencv\build\3rdparty\ade\ade-0.1.1c\sources\ade\source\alloc.cpp:31:77: error: 'posix_memalign' was not declared in this scope
     auto res = posix_memalign(&ret, std::max(sizeof(void*), alignment), size);
                                                                             ^
modules\CMakeFiles\ade.dir\build.make:62: recipe for target 'modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1c/sources/ade/source/alloc.cpp.obj' failed
mingw32-make[2]: *** [modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1c/sources/ade/source/alloc.cpp.obj] Error 1
CMakeFiles\Makefile2:980: recipe for target 'modules/CMakeFiles/ade.dir/all' failed
mingw32-make[1]: *** [modules/CMakeFiles/ade.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Is there any solution to tackle this issue ?