TextDetectionModel_EAST exception

Attempting to do text detection with the EAST model however currently running into an exception when calling detect.

void recongize_text(void* data, int width, int height) {
    TextDetectionModel_EAST* detector = new TextDetectionModel_EAST("frozen_east_text_detection.pb");

   double scale      = 1.0;
   Size input_size   = Size(width, height);
   Scalar mean       = Scalar(123.68, 116.78, 103.94);
   bool swap_rb      = true;
   float conf        = 0.5f;
   float nms        = 0.4f;
   detector->setConfidenceThreshold(conf)
      .setNMSThreshold(nms);
   detector->setInputParams(scale, input_size, mean, swap_rb);

   Mat image_mat = Mat(height, width, CV_8UC4, data);
   std::vector< std::vector<Point> > results;
   detector->detect(image_mat, results);

the exception occurs in dnn.cpp

layerSupportInPlace = l->getMemoryShapes(is, requiredOutputs, os, ints)

The following is the callstacks.

|>|opencv_world452d.dll!cv::dnn::dnn4_v20210301::Net::Impl::getLayerShapesRecursively(int id, std::map<int,cv::dnn::dnn4_v20210301::`anonymous namespace'::LayerShapes,std::less<int>,std::allocator<std::pair<int const ,cv::dnn::dnn4_v20210301::`anonymous namespace'::LayerShapes>>> & inOutShapes) Line 3505|C++|
|---|---|---|
| |opencv_world452d.dll!cv::dnn::dnn4_v20210301::Net::Impl::getLayersShapes(const std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> & netInputShapes, std::map<int,cv::dnn::dnn4_v20210301::`anonymous namespace'::LayerShapes,std::less<int>,std::allocator<std::pair<int const ,cv::dnn::dnn4_v20210301::`anonymous namespace'::LayerShapes>>> & inOutShapes) Line 3546|C++|
| |opencv_world452d.dll!cv::dnn::dnn4_v20210301::Net::Impl::allocateLayers(const std::vector<cv::dnn::dnn4_v20210301::LayerPin,std::allocator<cv::dnn::dnn4_v20210301::LayerPin>> & blobsToKeep_) Line 3138|C++|
| |opencv_world452d.dll!cv::dnn::dnn4_v20210301::Net::Impl::setUpNet(const std::vector<cv::dnn::dnn4_v20210301::LayerPin,std::allocator<cv::dnn::dnn4_v20210301::LayerPin>> & blobsToKeep_) Line 1463|C++|
| |opencv_world452d.dll!cv::dnn::dnn4_v20210301::Net::forward(const cv::debug_build_guard::_OutputArray & outputBlobs, const std::vector<std::string,std::allocator<std::string>> & outBlobNames) Line 4191|C++|
| |opencv_world452d.dll!cv::dnn::dnn4_v20210301::Model::Impl::processFrame(const cv::debug_build_guard::_InputArray & frame, const cv::debug_build_guard::_OutputArray & outs) Line 108|C++|
| |opencv_world452d.dll!cv::dnn::TextDetectionModel_EAST_Impl::detectTextRectangles(const cv::debug_build_guard::_InputArray & frame, std::vector<float,std::allocator<float>> & confidences) Line 887|C++|
| |opencv_world452d.dll!cv::dnn::TextDetectionModel_Impl::detect(const cv::debug_build_guard::_InputArray & frame, std::vector<float,std::allocator<float>> & confidences) Line 739|C++|
| |opencv_world452d.dll!cv::dnn::TextDetectionModel_Impl::detect(const cv::debug_build_guard::_InputArray & frame) Line 756|C++|
| |opencv_world452d.dll!cv::dnn::dnn4_v20210301::TextDetectionModel::detect(const cv::debug_build_guard::_InputArray & frame, std::vector<std::vector<cv::Point_<int>,std::allocator<cv::Point_<int>>>,std::allocator<std::vector<cv::Point_<int>,std::allocator<cv::Point_<int>>>>> & detections) Line 824|C++|

Any ideas? data seems to be a valid pointer with cpu read/write access. My data is 4 channels, each 1-byte. Changing input size doesnt seem to help.

Thanks.

ok, we got a stacktrace, but what is the exact exception ?

what are width , height ? (must be multiple of 32, see here:)

Thanks for the reply, after surrounding the detect->detect call with try/catch, I was able to see the exception. The model only supports 3 channels and not CV_8UC4.

1 Like