-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stitcher doesn't remove the black area #44
Labels
Comments
Need to convert this code to Java, since javacv doesn't have an easy way to access the pixel .. //find largest roi
bool cropLargestPossibleROI(const cv::Mat& gray, cv::Mat& pano, cv::Rect startROI)
{
// evaluate start-ROI
Mat possibleROI = gray(startROI);
bool topOk = checkRow(possibleROI, 0);
bool leftOk = checkColumn(possibleROI, 0);
bool bottomOk = checkRow(possibleROI, possibleROI.rows-1);
bool rightOk = checkColumn(possibleROI, possibleROI.cols-1);
if(topOk && leftOk && bottomOk && rightOk)
{
// Found!!
LOGE("cropLargestPossibleROI success");
pano = pano(startROI);
return true;
}
// If not, scale ROI down
Rect newROI(startROI.x, startROI.y, startROI.width, startROI.height);
// if x is increased, width has to be decreased to compensate
if(!leftOk)
{
newROI.x++;
newROI.width--;
}
// same is valid for y
if(!topOk)
{
newROI.y++;
newROI.height--;
}
if(!rightOk)
{
newROI.width--;
}
if(!bottomOk)
{
newROI.height--;
}
if(newROI.x + startROI.width < 0 || newROI.y + newROI.height < 0)
{
//sorry...
LOGE("cropLargestPossibleROI failed");
return false;
}
return cropLargestPossibleROI(gray,pano,newROI);
}
/check row
bool checkRow(const cv::Mat& roi, int y)
{
int zeroCount = 0;
for(int x=0; x<roi.cols; x++)
{
if(roi.at<uchar>(y, x) == 0)
{
zeroCount++;
}
}
if((zeroCount/(float)roi.cols)>cutBlackThreshold)
{
return false;
}
return true;
}
//check col
bool checkColumn(const cv::Mat& roi, int x)
{
int zeroCount = 0;
for(int y=0; y<roi.rows; y++)
{
if(roi.at<uchar>(y, x) == 0)
{
zeroCount++;
}
}
if((zeroCount/(float)roi.rows)>cutBlackThreshold)
{
return false;
}
return true;
} |
Yes we can easily access the pixel values using indexers:
http://bytedeco.org/news/2014/12/23/third-release/
|
Hi @indra365 Are you done with this things, Can you share the code crop the black area,.. Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
panorama stitcher doesn't crop the result image to remove that black area
The text was updated successfully, but these errors were encountered: