Do I need to do 4byte align(64bit 8byte align) in shallow copy and deep copy?

What is the reason for byte alignment?

shallow copy VS deep copy

  1. shallow copy
    cv::Mat image1 = cv::imread(PATH);
    cv::Mat image2(image1);
    cv::Mat image3 = image1;

  2. deep copy
    cv::Mat image4;
    image4.copyTo(image2);
    cv::Mat image5 = image3.clone();

Do I need to do 4byte align(64bit 8byte align) in shallow copy and deep copy?

you don’t need to because cv::Mat allocations are already aligned.

alignment is required by code that uses optimizations. most copying code uses optimizations. some copying code can handle misaligned data.