本文整理汇总了C++中BitMatrix::height方法的典型用法代码示例。如果您正苦于以下问题:C++ BitMatrix::height方法的具体用法?C++ BitMatrix::height怎么用?C++ BitMatrix::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMatrix
的用法示例。
在下文中一共展示了BitMatrix::height方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SizeOfBlackWhiteBlackRunBothWays
/**
* See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of
* a finder pattern by looking for a black-white-black run from the center in the direction
* of another point (another finder pattern center), and in the opposite direction too.
*/
static float SizeOfBlackWhiteBlackRunBothWays(const BitMatrix& image, int fromX, int fromY, int toX, int toY) {
float result = SizeOfBlackWhiteBlackRun(image, fromX, fromY, toX, toY);
// Now count other way -- don't run off image though of course
float scale = 1.0f;
int otherToX = fromX - (toX - fromX);
if (otherToX < 0) {
scale = (float)fromX / (float)(fromX - otherToX);
otherToX = 0;
}
else if (otherToX >= image.width()) {
scale = (float)(image.width() - 1 - fromX) / (float)(otherToX - fromX);
otherToX = image.width() - 1;
}
int otherToY = (int)(fromY - (toY - fromY) * scale);
scale = 1.0f;
if (otherToY < 0) {
scale = (float)fromY / (float)(fromY - otherToY);
otherToY = 0;
}
else if (otherToY >= image.height()) {
scale = (float)(image.height() - 1 - fromY) / (float)(otherToY - fromY);
otherToY = image.height() - 1;
}
otherToX = (int)(fromX + (otherToX - fromX) * scale);
result += SizeOfBlackWhiteBlackRun(image, fromX, fromY, otherToX, otherToY);
// Middle pixel is double-counted this way; subtract 1
return result - 1.0f;
}
示例2:
TEST(QRWriterTest, OverSize)
{
// The QR should be multiplied up to fit, with extra padding if necessary
int bigEnough = 256;
Writer writer;
BitMatrix matrix = writer.encode(L"http://www.google.com/", bigEnough, bigEnough);
EXPECT_EQ(matrix.width(), bigEnough);
EXPECT_EQ(matrix.height(), bigEnough);
// The QR will not fit in this size, so the matrix should come back bigger
int tooSmall = 20;
matrix = writer.encode(L"http://www.google.com/", tooSmall, tooSmall);
EXPECT_GT(matrix.width(), tooSmall);
EXPECT_GT(matrix.height(), tooSmall);
// We should also be able to handle non-square requests by padding them
int strangeWidth = 500;
int strangeHeight = 100;
matrix = writer.encode(L"http://www.google.com/", strangeWidth, strangeHeight);
EXPECT_EQ(matrix.width(), strangeWidth);
EXPECT_EQ(matrix.height(), strangeHeight);
}
示例3: ReadCodewords
ByteArray BitMatrixParser::ReadCodewords(const BitMatrix& image)
{
ByteArray result(144);
int height = image.height();
int width = image.width();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int bit = BITNR[y][x];
if (bit >= 0 && image.get(x, y)) {
result[bit / 6] |= static_cast<uint8_t>(1 << (5 - (bit % 6)));
}
}
}
return result;
}
示例4: FindAlignmentInRegion
/**
* <p>Attempts to locate an alignment pattern in a limited region of the image, which is
* guessed to contain it. This method uses {@link AlignmentPattern}.</p>
*
* @param overallEstModuleSize estimated module size so far
* @param estAlignmentX x coordinate of center of area probably containing alignment pattern
* @param estAlignmentY y coordinate of above
* @param allowanceFactor number of pixels in all directions to search from the center
* @return {@link AlignmentPattern} if found, or null otherwise
* @throws NotFoundException if an unexpected error occurs during detection
*/
AlignmentPattern FindAlignmentInRegion(const BitMatrix& image, float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor)
{
// Look for an alignment pattern (3 modules in size) around where it
// should be
int allowance = (int)(allowanceFactor * overallEstModuleSize);
int alignmentAreaLeftX = std::max(0, estAlignmentX - allowance);
int alignmentAreaRightX = std::min(image.width() - 1, estAlignmentX + allowance);
if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
return {};
}
int alignmentAreaTopY = std::max(0, estAlignmentY - allowance);
int alignmentAreaBottomY = std::min(image.height() - 1, estAlignmentY + allowance);
if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
return {};
}
return AlignmentPatternFinder::Find(image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize);
}
示例5: Detect
bool WhiteRectDetector::Detect(const BitMatrix& image, ResultPoint& p0, ResultPoint& p1, ResultPoint& p2, ResultPoint& p3)
{
return Detect(image, INIT_SIZE, image.width() / 2, image.height() / 2, p0, p1, p2, p3);
}