コード例 #1
0
Mat prepare(Mat input, int blockSize, double C ){
    //Mat gray = convertToGray(input);
    Mat gray = input;
    Mat bw;
    
    adaptiveThreshold(~gray, bw, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, blockSize, C);
    
    
    Mat horizontal = getHorizontal(bw);
    Mat vertical = getVertical(bw);
    
    
    
    Mat edges;
    adaptiveThreshold(horizontal, edges, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 3, -2);
    
    Mat kernel = Mat::ones(2, 2, CV_8UC1);
    dilate(edges, edges, kernel);
    
    Mat smooth;
    vertical.copyTo(smooth);
    
    blur(smooth, smooth, Size(2, 2));
    
    smooth.copyTo(horizontal, edges);
    return horizontal;
}
コード例 #2
0
void Octorok::shot() {
    SoundManager::playSound("shootBigBall");
    sf::Vector2f offset;
    offset.x = getHorizontal(_dir) * (getBounds().left+getBounds().width /2);
    offset.y = getVertical  (_dir) * (getBounds().top +getBounds().height/2);
    _scene->addEnemyWeapon(new RockProjectile(_map, getRelativeCenter(_sprite.getPosition(), getBounds(), RockProjectile::bounds()) + offset, _dir));
}
コード例 #3
0
ファイル: assignment2.cpp プロジェクト: adamjford/assignment2
void loop() {
  uint8_t ratingFilter = getRatingFilter();
  uint16_t horiz = getHorizontal();
  uint16_t vert = getVertical();
  lightUpRatingLEDs(ratingFilter);

  tft.drawPixel(horiz, vert, 0);
  if(isButtonPressed()) {
    // wait for button to be released
    while(isButtonPressed()) { }
    displayClosestRestaurants(horiz, vert, ratingFilter * 2);
    drawMap();
  }
  lcd_image_draw(&map_image, &tft, horiz, vert, horiz, vert, 1, 1);
}
コード例 #4
0
ファイル: State.cpp プロジェクト: lockpick/Omok
void State::update()
{
    _attackables.clear();
    //vertical
    for (size_t i = 0; i < _size; ++i) {
        auto v = getVertical(Position(0, i));
        updateLine(v);
    }
    //horizontal
    for (size_t i = 0; i < _size; ++i) {
        auto v = getHorizontal(Position(i, 0));
        updateLine(v);
    }
    //diagonalA
    for (size_t i = 4; i < _size-1; ++i) {
        auto v = getDiagonalA(Position(i, _size-1));
        updateLine(v);
    }
    {
        auto v = getDiagonalA(Position(_size - 1, _size - 1));
        updateLine(v);
    }
    for (size_t i = 1; i < _size - 4; ++i) {
        auto v = getDiagonalA(Position(i, 0));
        updateLine(v);
    }
    //diagonalB
    for (size_t i = 4; i < _size - 1; ++i) {
        auto v = getDiagonalB(Position(i, 0));
        updateLine(v);
    }
    {
        auto v = getDiagonalB(Position(_size - 1, 0));
        updateLine(v);
    }
    for (size_t i = 1; i < _size - 4; ++i) {
        auto v = getDiagonalB(Position(i, _size - 1));
        updateLine(v);
    }
    updated = true;
}
コード例 #5
0
 glm::vec3 getScreenUp() const {
   return glm::normalize(glm::cross(getHorizontal(),getDirection()));
 }
コード例 #6
0
ファイル: Input.cpp プロジェクト: trudeHisa/workspace
const GSvector2& Input::getVelocity()const
{
	GSvector2 vel(getHorizontal(),getVertical());
	return vel.normalize();
}
コード例 #7
0
// Compute character width, based on window size and font.
float df::GraphicsManager::charWidth(){
	return (float)getHorizontalPixels() / (float)getHorizontal();
}
コード例 #8
0
ファイル: State.cpp プロジェクト: lockpick/Omok
bool State::isForbidden(Position p, Block b, const Test &test) const
{
    bool isForbidden = true;

    size_t count33 = 0;
    auto check33 = [&](Test t) {
        auto iter = std::find(t->position.cbegin(), t->position.cend(), p);
        assert(iter != t->position.cend());
        size_t i = iter - t->position.cbegin();
        assert(i < t->line.size());
        t->line[i] = b;

        size_t count = 0;
        for (size_t j = i+1; j < t->line.size(); ++j) {
            if (t->line[j] != b)
                break;
            ++count;
        }

        bool isS3 = false;

        if (isS3 == false  && count < 3 && i > 0 && t->line[i - 1] == SPACE) {
            auto attackable = check3(t, i);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count < 2 && i > 1 && t->line[i - 1] == b && t->line[i - 2] == SPACE) {
            auto attackable = check3(t, i - 1);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count == 0 && i > 2 && t->line[i - 1] == b && t->line[i - 2] == b && t->line[i - 3] == SPACE) {
            auto attackable = check3(t, i - 2);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count < 2 && i > 2 && t->line[i - 1] == SPACE && t->line[i - 2] == b && t->line[i - 3] == SPACE) {
            auto attackable = check3(t, i - 2);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3 == false && count == 0 &&  i > 3 && t->line[i - 1] == SPACE && t->line[i - 2] == b && t->line[i - 3] == b && t->line[i  - 4] == SPACE) {
            auto attackable = check3(t, i - 3);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3 == false && count == 0 && i > 3 && t->line[i - 1] == b && t->line[i - 2] == SPACE && t->line[i - 3] == b && t->line[i - 4] == SPACE) {
            auto attackable = check3(t, i - 3);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3) {
            ++count33;
        }
    };

    if (get(p) == SPACE) {
        isForbidden = false;
        auto vertical = getVertical(p);
        auto horizontal = getHorizontal(p);
        auto diagonalA = getDiagonalA(p);
        auto diagonalB = getDiagonalB(p);
        if (test) {
            if (vertical->position.front() == test->position.front()
                && vertical->position.back() == test->position.back()) {
                vertical = test;
            }
            else if (horizontal->position.front() == test->position.front()
                && horizontal->position.back() == test->position.back()) {
                horizontal = test;
            }
            else if (diagonalA->position.front() == test->position.front()
                && diagonalA->position.back() == test->position.back()) {
                diagonalA = test;
            }
            else if (diagonalB->position.front() == test->position.front()
                && diagonalB->position.back() == test->position.back()) {
                diagonalB = test;
            }
        }

        Rule *rule = b == BLACK ? Rule::getBlack() : Rule::getWhite();
        if (rule->getThreeAndThree() == false) {
            check33(vertical);
            check33(horizontal);
            if (diagonalA->line.size() > 0) {
                check33(diagonalA);
            }
            if (diagonalB->line.size() > 0) {
                check33(diagonalB);
            }
            if (count33 > 1) {
                isForbidden = true;
            }
        }
    }
    return isForbidden;
}