- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在做我的项目,我遇到了一个问题,我不知道如何只从一个以前检测过的方形区域检测关键点。下面是我的演示,到目前为止,我的代码会检测正方形内外的关键点:https://www.youtube.com/watch?feature=player_embedded&v=3U8V6PhMnZ8
这是我找到正方形的代码:
const int threshold_level = 2;
for (int l = 0; l < threshold_level; l++)
{
gray = gray0 >= (l+1) * 255 / threshold_level;
// Find contours and store them in a list
findContours(gray, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
// Test contours
vector<Point> approx;
for (size_t i = 0; i < contours.size(); i++)
{
// approximate contour with accuracy proportional
// to the contour perimeter
approxPolyDP(Mat(contours[i]), approx, arcLength(Mat(contours[i]), true)*0.02, true);
// Note: absolute value of an area is used because
// area may be positive or negative - in accordance with the
// contour orientation
if (approx.size() == 4 &&
fabs(contourArea(Mat(approx))) > 3000 &&
isContourConvex(Mat(approx)))
{
double maxCosine = 0;
for (int j = 2; j < 5; j++)
{
double cosine = fabs(angle(approx[j%4], approx[j-2], approx[j-1]));
maxCosine = MAX(maxCosine, cosine);
}
if (maxCosine < 0.3)
squares.push_back(approx);
}
}
}
这是我绘制正方形和角点的代码:
const Point* p = &squares[i][0];
int n = (int)squares[i].size();
Point p1 = squares[i][0];
Point p2 = squares[i][1];
Point p3 = squares[i][2];
Point p4 = squares[i][3];
cout<<"p1 is "<<p1<<" p2 is "<<p2<<" p3 is "<<p3<<" p4 is "<<p4<<endl;
circle(image, squares[i][0], 3, Scalar(0,0,255), 5, 8, 0);
circle(image, squares[i][1], 3, Scalar(0,255,255), 5, 8, 0);
circle(image, squares[i][2], 3, Scalar(255,0,255), 5, 8, 0);
circle(image, squares[i][3], 3, Scalar(255,255,0), 5, 8, 0);
polylines(image, &p, &n, 1, true, Scalar(0,255,0), 3, CV_AA);
这是我检测关键点的代码:
Mat gray_image;
vector<KeyPoint> keyPoints;
cvtColor(image, gray_image, CV_BGR2GRAY);
FastFeatureDetector fast(60);
fast.detect(gray_image,keyPoints);
drawKeypoints(image, keyPoints,image, Scalar::all(255), DrawMatchesFlags::DRAW_OVER_OUTIMG);
最佳答案
您可以使用裁剪图像
Rect r(left,top,width,height);//我们感兴趣的部分图片
Mat roi(fullImage, r);//将创建对原始图像的矩形 r 的引用。请注意,它不是拷贝。
关于c++ - opencv/c++ 我如何只检测之前检测到的方形区域内的关键点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14379212/
我目前有一个程序,可以简单地在屏幕上绘制一个正方形,但是,我试图向这个正方形添加垂直线,它确实打印到屏幕上,但不是它定义的完整长度,而且不是广场内。任何帮助将不胜感激! #include int m
.products { width: 100%; height: 500px; background: gray; } .box { width: 250px; height: 3
I need the square-symbolized character have the square shape that fills entire the character's area,
我们应该知道,Clojure 的 map 可以应用于序列: (map #(* %1 %1) [1 2 3]) ; (1) ..或者多个,通过这种方式: (map vector [0
我正在尝试用 HTML/CSS 制作类似这样的东西:https://gyazo.com/6db0d2e3565414c10b65480c5d4b7526 我正在使用一个 Bootstrap 模板,我想
当我为我的 fab 设置颜色时,它看起来像这样: 我的布局 xml: 颜色也不会改变。谁能帮助我理解我做错了什么? 我也尝试过使用 @color 链接但它崩溃了,背景是可绘制的 (ex. andr
我有一个带有圆形图像的自定义按钮。 问题是 Controller 默认是方形的,所以每当我单击图像的角时,按钮都会响应调用关联的方法,而实际上他不应该这样做,因为角上没有图像,所以按钮不应响应。 有人
您好,我的页面顶部有一个 div http://www.uk-sf.com/MyTraining.php box-shadow 被切割在 wrapper 上,我试着给它一个 z-index 但没有任何
我有一个包含图像的 div。此图像仅在元素悬停时显示,因此我希望侧箭头从指向侧面的 div 出来(在元素悬停的方向)。 此代码生成正方形 div: CSS: #image-t
我在 Android 项目中使用 ImageView。 宽度:match_parent高度:wrap_content 然后我将它缩放到 fill_XY,但图像还不是正方形...我该怎么办? 最佳答案
我正在尝试使用 div 创建一个 2x2 网格。一些 div 可能包含图像,但它可能会被设置为背景,选项为 background-size: cover。 这是我创建的笔:http://codepen
* { box-sizing: border-box; } .publication { display: flex;
我有以下代码: 结果: 如何使 View 的高度与其宽度相等(由 layout_weight 产生)? 最佳答案 您必须重写 onMeasure 方法,将高度设置为与高度相
我正在开发照片编辑应用程序,我有 3 个带有 UIImageview 的 ScrollView ,我想将 ScrollView 设置如下 我试过“Scenekit”,但它不起作用,因为我想要 Scro
在不使用 SVG 图像的情况下,使用 React 可以在其中包含自定义文本来创建圆形和方形的方法是什么?一个例子: 我尝试了以下代码,但它没有呈现任何形状: import React from 're
我想要一个没有滚动条的响应式 9x9 div 网格。 div 网格应根据可见的浏览器窗口调整大小。我合并了"How to maintain the aspect ratio of a div usin
我第一次尝试使用Picasso 如官方网站示例: private void setItemBgImageUsingPicasso(View convertView) { String imag
尝试为 Android 使用 Dagger 依赖注入(inject)器。这是扩展的应用程序类: public class MyApplication extends Application {
我使用 Bootstrap 3 的 .thumbnail 类创建了一个图像网格。在调整图像大小和根据窗口大小更改列方面,一切似乎都很好。唯一的问题是图像的大小各不相同,并且纵向/横向都是。这会导致缩略
我正尝试通过 Square 在我的 iOS 应用程序中实现 OAuth2,但它说当我通过弹出的浏览器成功登录时,我的 redirect_uri 出现错误。 我正在使用 OAuthSwift pod。这
我是一名优秀的程序员,十分优秀!