小编and*_*oga的帖子

七个Hu不变矩的意义来自OpenCV

据我所知,七个hu不变矩用于对象的平移,旋转和比例变化,以便独立地识别这些因素.

这就是为什么我使用OpenCV中的"时刻"功能来提取中心时刻,然后我使用函数HuMoments来获得下面二值化图像的七个不变矩:

在此输入图像描述

我的第一个问题是关于使用OpenCV的"时刻"功能.第二个参数是"binaryImage",我将其设置为true,因为它是二进制图像,可以吗?

我的第二个疑问是关于"HuMoments"功能的输出:七个hu不变的时刻.我不明白这些数据.什么数据与轮换,翻译什么以及规模变化有什么关系?

非常感谢!欢呼!

c++ opencv image-processing computer-vision

17
推荐指数
1
解决办法
2万
查看次数

n-gram是所有单词中最常见的一个

我遇到了以下编程面试问题:

挑战1:N克

N-gram是来自给定单词的N个连续字符的序列.对于"飞行员"这个词,有三个3克:"pil","ilo"和"lot".对于给定的单词集和n-gram长度,您的任务是

• write a function that finds the n-gram that is the most frequent one among all the words
• print the result to the standard output (stdout)
• if there are multiple n-grams having the same maximum frequency please print the one that is the smallest lexicographically (the first one according to the dictionary sorting order)
Run Code Online (Sandbox Code Playgroud)

请注意,您的函数将收到以下参数:

• text
    ? which is a string containing words separated by whitespaces
• ngramLength
    ? which is an integer value …
Run Code Online (Sandbox Code Playgroud)

c algorithm n-gram

7
推荐指数
1
解决办法
5322
查看次数

Android - 可检查菜单项的问题

我已经阅读了android开发者页面上的说明,以获取Checkable菜单项:

http://developer.android.com/guide/topics/ui/menus.html

这是我的xmlmenu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="all">
        <item android:id="@+id/regu"
              android:title="@string/Regulatory" />
        <item android:id="@+id/warn"
              android:title="@string/Warning" />
        <item android:id="@+id/temp"
              android:title="@string/Temporary" />
        <item android:id="@+id/bicy"
              android:title="@string/Bicycle" />
    </group>
</menu>
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

 @Override
    public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
      case R.id.regu:
          if (item.isChecked())
          {
              item.setChecked(false);
              currAvailableOptions++;
          }
          else if(0 != currAvailableOptions)
          {
                  item.setChecked(true);
                  currAvailableOptions--;
          }
          return true;
      case R.id.warn:
          if (item.isChecked())
          {
              item.setChecked(false);
              currAvailableOptions++;
          }
          else if(0 != currAvailableOptions)
          {
                  item.setChecked(true);
                  currAvailableOptions--;
          }
        return true;
      case R.id.temp:
          if (item.isChecked())
          {
              item.setChecked(false); …
Run Code Online (Sandbox Code Playgroud)

checkbox android menu items

6
推荐指数
1
解决办法
7333
查看次数

帮助使用扩张功能OpenCV

在下面的代码中我想使用该dilate函数,但我不知道如何将Mat类转换为InputArrayOutputArray.你能帮助我吗?

使用这个原型函数:

void dilate(InputArray src, OutputArray dst, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

#include "opencv2/opencv.hpp"

using namespace cv;

int main(int, char**)
{
    Mat edges;

    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;


    for(;;)
    {

        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, CV_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
        //dilate(edges,edges,NULL);
        Canny(edges, edges, 0, …
Run Code Online (Sandbox Code Playgroud)

c++ opencv function image-processing mathematical-morphology

6
推荐指数
1
解决办法
1万
查看次数