(vision): fix SUltrasoundImage's hack
Summary
In cvSegmentation::SUltrasounImage
, a hack has been used to avoid useless copy as explained in the code snipet below:
// HACK: Const cast to avoid a useless copy, fix this by overloading the `moveToCv` function to
// take a `::fwData::Image::cpstr` and output `const ::cv::Mat`.
const auto constImage = this->getLockedInput< ::fwData::Image >(s_ULTRASOUND_IMAGE_INPUT);
::fwData::Image::sptr inputImage = ::fwData::Image::constCast(constImage.get_shared());
SLM_ASSERT("Missing input frame.", inputImage);
const bool isValid = ::fwDataTools::fieldHelper::MedicalImageHelpers::checkImageValidity(inputImage);
if(!isValid)
{
return;
}
const ::cv::Mat src = ::cvIO::Image::moveToCv(inputImage);
Unfortunately, by using the moveToCv
method we share the buffer between the input image inputImage
and the cv::Mat src
and when we modify the parameters with SParameters
we do not use the original input image but the modified one.
To illustrate the bug, after displaying one ultrasound extracted frame, when we reset the depth parameter via SParameters
, for example, the extracted frame is modified and get smaller everytime with click on reset.
Relevant logs and/or screenshots
Possible fixes
replace the methodmoveToCv
bycopyToCv
and remove the constCast to keep the normal constant locked input- This service is deprecated and should simply be removed.