fix detection of thin staffs (probably) in vector graphs

This commit is contained in:
Liang Chen 2016-07-04 17:36:03 -04:00
parent 863c9ac1fd
commit 9736a2a8cf
3 changed files with 8 additions and 6 deletions

View file

@ -42,6 +42,6 @@ If S(I(i,j)) is larger than 0, we say at position (i,j) there's a symbols candid
[Screenshots of some results](https://musescore.org/en/node/110306#comment-500796)
###Todo
* Add robust note detector to impose negative constraints for bar line identification. (see [here](https://github.com/liang-chen/MuseScore/blob/omr/omr/omrpage.cpp#L288))
* Add robust note detector to impose negative constraints for bar line identification. (see [here](https://github.com/musescore/MuseScore/blob/master/omr/omrpage.cpp#L292))
* Fix staff detection for vector graphs
* Optimize OMR performance and add clef/key recognitions

View file

@ -216,7 +216,7 @@ bool Omr::omrActions(int &ID, int page)
//load one page and rescale
_pages[page]->read();
//do the rescaling of image here
//do the rescaling here
int new_w = _pages[page]->image().width() * _spatium/_pages[page]->spatium();
int new_h = _pages[page]->image().height() * _spatium/_pages[page]->spatium();
QImage image = _pages[page]->image().scaled(new_w,new_h, Qt::KeepAspectRatio);

View file

@ -105,7 +105,7 @@ bool OmrPage::isBlack(int x, int y) const
void OmrPage::read()
{
removeBorder();
//removeBorder();
crop();
slice();
deSkew();
@ -1096,6 +1096,7 @@ void OmrPage::readHeader(Score*)
void OmrPage::removeBorder()
{
#if 0
cropT = cropB = cropL = cropR = 0;
for (int y = 0; y < height(); ++y) {
for (int x = 0; x < width(); ++x) {
@ -1145,6 +1146,7 @@ void OmrPage::removeBorder()
}
_image = _image.copy(cropL, cropT, cropR - cropL + 1, cropB - cropT + 1);
#endif
}
//---------------------------------------------------------
@ -1471,7 +1473,7 @@ void OmrPage::getStaffLines()
projection[y] = 0;
for (int y = y1; y < y2; ++y)
projection[y] = xproject2(y);
int autoTableSize = (wl * 32) / 10; // 1/10 page width
int autoTableSize = (wl * 32) / 20; // 1/20 page width
if (autoTableSize > y2 - y1)
autoTableSize = y2 - y1;
double autoTable[autoTableSize];
@ -1486,7 +1488,7 @@ void OmrPage::getStaffLines()
//
double maxCorrelation = 0;
_spatium = 0;
for (int i = 10; i < autoTableSize; ++i) {
for (int i = 5; i < autoTableSize; ++i) {
if (autoTable[i] > maxCorrelation) {
maxCorrelation = autoTable[i];
_spatium = i;
@ -1534,7 +1536,7 @@ void OmrPage::getStaffLines()
}
qSort(staveTop.begin(), staveTop.end(), sortLvStaves);
foreach (Lv a, staveTop) {
staves.append(OmrStaff(cropL * 32, a.line, width() - cropR * 32, _spatium * 4));
staves.append(OmrStaff(cropL * 32, a.line, (wordsPerLine() - cropL - cropR) * 32, _spatium * 4));
}
}