How to fill Matrix with zeros in OpenCV?

前端 未结 8 1001
-上瘾入骨i
-上瘾入骨i 2020-12-15 03:36

The code below causes an exception. Why?

#include 
#include 

using namespace cv;
using namespace std;

void mai         


        
8条回答
  •  甜味超标
    2020-12-15 04:21

    You can choose filling zero data or create zero Mat.

    1. Filling zero data with setTo():

      img.setTo(Scalar::all(0));
      
    2. Create zero data with zeros():

      img = zeros(img.size(), img.type());
      

    The img changes address of memory.

提交回复
热议问题