小编Sch*_*tze的帖子

Git ignore不会忽略指定的文件夹/文件

我希望我的.gitignore忽略某些文件夹和文件,所以我想出了以下内容:

*.class

# usual java ignores
bin/
.metadata

# Maven
*/target/*
target/*
/target/
*/deploy/*
deploy/*

# src-gen folder is populated by the command of protobuf, these files should not be pushed
src-gen/*

# eclipse generated stuff
dependency-reduced-pom.xml

# we shouldn't have .jar files in our repository, 
# apart from these 5 jars which are vital for our build process
*.jar
!/projectName/bundle/**/*.jar

# For Unix editors 
# sometimes make file copies ending
# with ~
# To ignore them use:
*~ …
Run Code Online (Sandbox Code Playgroud)

git gitignore

6
推荐指数
2
解决办法
4803
查看次数

Python3 双向串行通信:读入数据

我正在尝试通过 Python3 建立双向通信。有一个激光测距仪插入我的一个 USB 端口,我想向它发送/接收命令。我有一张可以发送的命令以及它们会返回什么,所以这部分已经存在了。

我需要的是一种实时进行的便捷方式。到目前为止,我有以下代码:

import serial, time

SERIALPORT = "/dev/ttyUSB0"
BAUDRATE = 115200

ser = serial.Serial(SERIALPORT, BAUDRATE)
ser.bytesize = serial.EIGHTBITS #number of bits per bytes
ser.parity = serial.PARITY_NONE #set parity check: no parity
ser.stopbits = serial.STOPBITS_ONE #number of stop bits
ser.timeout = None          #block read
ser.xonxoff = False     #disable software flow control
ser.rtscts = False     #disable hardware (RTS/CTS) flow control
ser.dsrdtr = False       #disable hardware (DSR/DTR) flow control
ser.writeTimeout = 0     #timeout for write

print ("Starting Up Serial …
Run Code Online (Sandbox Code Playgroud)

serial-port pyserial python-3.x

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

Git:使用可执行文件

我有一个项目,其中有一个.sh文件,一旦被其他人拉取,它就必须处于可执行模式。现在,我已经在本地计算机上更改了其权限。不过,我希望它也作为可执行文件推送/拉取,以便其他用户不必chmod一直运行命令。

我已被告知两种可能的解决方案:.gitattributesgit update-index --chmod=+x script.sh,但是考虑到我的情况,我不确定我到底应该遵循什么。

我在这里看到了这篇文章,在那里看到了这个答案,我在想哪一个更适合我的情况。我希望这个过程自动完成,而不是每次都由用户添加。

有什么想法吗?

linux git bash executable gitattributes

5
推荐指数
1
解决办法
4171
查看次数

Ubuntu 18.04:找不到 CMAKE_C_COMPILER

我正在尝试从 Google 安装 gtest,但即使我安装了 gcc 和 g++,由于某种原因我还是收到了这个错误。我在 Ubuntu 18.04 64 位上。而且我与 Visual Studio 的东西没有任何关系。

-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:47 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/usr/src/googletest/googletest/CMakeFiles/CMakeOutput.log".
See also "/usr/src/googletest/googletest/CMakeFiles/CMakeError.log". …
Run Code Online (Sandbox Code Playgroud)

gcc g++ ubuntu-18.04

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

exec maven 插件:退出代码

我有以下插件来运行.sh脚本:

<plugin>
  <artifactId>exec-maven-plugin</artifactId>
  <groupId>org.codehaus.mojo</groupId>
  <executions>
    <execution>
      <id>deploy-bundles</id>
      <phase>install</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>${basedir}/deploy.sh</executable>
        <successCodes>
            <successCode>0</successCode> <-- Not working
        </successCodes>
      </configuration>
    </execution>
  </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

它将一些文件夹和文件复制到某些位置。有用。但是,为了以防万一,我希望有一个失败错误机制。set -e我的.sh脚本中已经有了命令,但我也想要一个 Maven 解决方案。我听说有一个名为的标签successCodes,我尝试合并它。但到目前为止没有运气。有人能指出正确的做法吗?

编辑:我的.sh脚本如下所示:

cp ../template/config.properties $component/conf
cp ../../runtime/group1/group1.mw/conf/log4j.xml $component/conf
# if the component is planning, create an additional folder called plans
if [[ $component == *".planning"* ]] 
then
mkdir -p $component/plans
    # copy all the plans here
    cp ../../mission.planning/plans/* $component/plans
fi  
Run Code Online (Sandbox Code Playgroud)

如果这些文件夹/文件不存在,预计会失败。因此,作为测试,我手动更改了上面的路径并期望它失败。它确实使执行过程失败并告诉我错误(因为我set …

bash maven exec-maven-plugin

4
推荐指数
1
解决办法
6662
查看次数

OpenCV VideoWriter 大小问题

我正在尝试读取视频文件,对其进行处理,并将处理后的帧作为输出视频文件写入。但是,我收到以下错误:

    OpenCV Error: Assertion failed (img.cols == width && img.rows == height && channels == 3) in write, file /.../opencv-cpp/modules/videoio/src/cap_mjpeg_encoder.cpp, line 829
    terminate called after throwing an instance of 'cv::Exception'
      what():  /.../opencv-cpp/modules/videoio/src/cap_mjpeg_encoder.cpp:829: error: (-215) img.cols == width && img.rows == height && channels == 3 in function write
Run Code Online (Sandbox Code Playgroud)

我确定我有 3 个频道(我用 进行了检查.channels()),然后write()功能发生了:

//generate video
cout<<finalOutputRGB.channels()<<endl;
outputCapRGB.write(finalOutputRGB);
Run Code Online (Sandbox Code Playgroud)

所以问题不在这里。也许是我初始化的方式?

// Setup output videos
VideoWriter outputCapRGB(rgbVideoOutputPath, captureRGB.get(CV_CAP_PROP_FOURCC), captureRGB.get(CV_CAP_PROP_FPS),
Size(captureRGB.get(CV_CAP_PROP_FRAME_WIDTH), captureRGB.get(CV_CAP_PROP_FRAME_HEIGHT)));
Run Code Online (Sandbox Code Playgroud)

会是什么呢?我想到的一件事是,在处理帧的过程中,它们被裁剪,因此分辨率不一样。也许这就是原因。但是话又说回来,OpenCV 不允许录制任何修改过的视频是愚蠢的。

因此,我尝试使用裁剪后的帧大小创建视频编写器对象,如下所示:

// Sizes of the videos to …
Run Code Online (Sandbox Code Playgroud)

c++ opencv

4
推荐指数
1
解决办法
8662
查看次数

C++:从某个时间戳启动一个计时器,然后递增它

我正在尝试编写一个程序,它将处理一个视频文件,并将随之处理一个计时器.每个视频文件.txt旁边都有一个文件,包括实时拍摄视频的时间(如13:43:21),我希望我的程序读取此.txt文件,并从该特定时间戳启动计时器,并勾选因为它在视频文件中打勾.

到目前为止,我已经可以读取.txt文件,并且我将开始时间存储在string变量中.现在,我想要做的是,创建一个计时器,它将从读取字符串变量开始并在视频播放时打勾,以便在我的程序中我与视频中的时间滴答同步.

编辑:我使用OpenCV作为库.

c++ opencv timer

4
推荐指数
1
解决办法
458
查看次数

PCL:无法找到字段“rgba”的匹配项

我正在使用 PCL 页面中两个项目的教程代码。一是保存点云,二是可视化(令人沮丧的是,这两者都不存在于一个简单的项目中,令人难以置信)。

这就是我拯救云的方式:

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int
  main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ> cloud;

  // Fill in the cloud data
  cloud.width    = 5;
  cloud.height   = 1;
  cloud.is_dense = false;
  cloud.points.resize (cloud.width * cloud.height);

  for (size_t i = 0; i < cloud.points.size (); ++i)
  {
    cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
  } …
Run Code Online (Sandbox Code Playgroud)

c++ point-clouds point-cloud-library

4
推荐指数
1
解决办法
4149
查看次数

exec-maven-plugin 无法执行 .sh 脚本:权限被拒绝

我有一个 bash 脚本,我希望 Maven 在编译阶段后运行它,因为该脚本应该部署包。这是我尝试在发布模块中使用的插件:

<plugin>
          <artifactId>exec-maven-plugin</artifactId>
          <groupId>org.codehaus.mojo</groupId>
          <executions>
            <execution>
              <id>deploy-bundles</id>
              <phase>install</phase>
              <goals>
                <goal>exec</goal>
              </goals>
              <configuration>
                <executable>${basedir}/deploy.sh</executable>
              </configuration>
            </execution>
          </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

我的deploy.sh路径正确,因此已得到验证。现在,当我这样做时,mvn install出现以下错误:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (deploy-bundles) on project module.release: Command execution failed. Cannot run program "/bla/bla/module.release/deploy.sh" (in directory "/bla/bla/module.release"): error=13, Permission denied -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

首先,我认为这与我编写的 bash 脚本有关。所以我把它改成了一个简单的 bash 脚本,如下所示:

#!/bin/bash          
STR="Hello World!"
echo $STR    
Run Code Online (Sandbox Code Playgroud)

但是,我遇到了同样的错误。所以这与代码无关。我应该给予maven特殊的权利吗?应该使用sudo命令吗?

bash maven exec-maven-plugin

3
推荐指数
1
解决办法
7476
查看次数

在安装阶段通过maven-plugin清除本地Maven存储库

我想.m2/repository在安装阶段之前删除整个存储库()的内容。当然,我不想手工完成,因此我正在寻找一款具有魔力的插件。到目前为止,我遇到了,maven-clean-plugin并且我正尝试按以下方式使用它:

<build>
      <sourceDirectory>src/</sourceDirectory>
      <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>${jdk.version}</source>
               <target>${jdk.version}</target>
            </configuration>
        </plugin>  
        <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
        <filesets>
                  <fileset>
                      <directory>${settings.localRepository}/</directory>
                      <includes>
                          <include>**/*</include>
                      </includes>
                  </fileset>
        </filesets>
        </configuration>
        <executions>
          <execution>
            <id>auto-clean</id>
            <phase>install</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      </plugins>
   </build>
Run Code Online (Sandbox Code Playgroud)

我希望这可以在下载新的工件之前清除整个存储库,最后target从模块中删除该文件夹。删除target文件夹是可行的,但是清除存储库还是行不通的。它确实清除了存储库,但是随后Maven抱怨缺少所需的某些工件,因此编译失败并返回以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.3:resources (default-resources) on project com.google.protobuf: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.3:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.3 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.3 -> [Help …
Run Code Online (Sandbox Code Playgroud)

maven maven-clean-plugin

0
推荐指数
1
解决办法
406
查看次数