How to run opencv sample surf matcher? - c++

I tried to run this sample code from opencv but I'm confused as to how to run it. It only shows this help message:
Usage: surf_matcher[options]
Available options:
Usage: surf_matcher_2.exe [params]
--cpu_mode, -m (value:false)
run without OpenCL
-h, --help (value:false)
print help message
-l, --1eft (value: box.png)
specify left image
-o, --output (value: SURF output . jpg)
specify output save path
-r, --right (value: box in scene.png)
specify right image
From my basic understanding of arguments, I tried many kinds of input arguments as follows:
-l box.png -r box_in_scene.png
--left box.png --right box_in_scene.png
--l box.png --r box_in_scene.png
But it still did not work. It did have this error but built successfully:
Severity Code Description Project File Line Suppression State
Error (active) the default constructor of "SURFMatcher<cv::BFMatcher>" cannot be referenced -- it is a deleted function surf_matcher_2 c:\Users\user\Documents\Visual Studio 2015\Projects\surf_matcher_2\surf_matcher_2\surf_matcher_2.cpp 195
I got it to run a long time ago but replicating the old project didn't work either.

The syntax to use for CommandLineParser is a bit different. You need to put = after the option. Like this:
-l=box.png -r=box_in_scene.png -o=out.png
or
--left=box.png --right=box_in_scene.png --output=out.png
Be sure to put the correct path for the images.

Related

I can't knit my rmarkdown files - pandoc error

My university provided laptop was recently replaced and now when I try to knit my Rmd files if get the following error:
pandoc.exe: \\: openBinaryFile: invalid argument (Invalid argument)
Error: pandoc document conversion failed with error 1
Execution halted
These files used to knit perfectly on my old laptop and all of the code blocks within the file still run without errors.
The pandoc_available() function returns TRUE
The answers to similar questions that I have searched suggest it is something to do with the file paths but I am not familiar enough with this to make sense of what I should do. I tried mapping a network drive (Z:) to the folder where the Rmd file is stored and then changing the working directory in RStudio to that drive but it hasn't helped (and now I don't know how to change it back to ~ or what that referred to in the first place)
I have also tried downloading the latest version of Pandoc and a search on Windows Explorer shows that has installed in my user directory but I also have a version in C:\Program Files\RStudio\bin. That has also not helped.
I'm not sure if this is relevant but here is the information on the R version that I am running:
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
Can you tell me what other information is required to diagnose the problem and I will edit to include.
I am sorry this question is so poorly specified and would appreciate any help to improve it.
**** UPDATE ****
I have found that if I
(i) specify that I want a .md file in the YAML header,
(ii) create an .md file by knitting the markdown file,
(iii) copy that .md file manually to the Pandoc directory
(iv) run pandoc.exe -s -o test.knit.md test.html from the MSDOS command prompt within the Pandoc directory,
then I can create the html output file.
However, changing the working directory for RStudio to the Pandoc directory and running
x <- rmarkdown::render("test.Rmd", run_pandoc = FALSE, clean = FALSE)
knit_meta <- attr(x, "knit_meta")
rmarkdown::render( input = 'test.knit.md' , knit_meta = knit_meta )
as per https://stackoverflow.com/questions/38908766/how-to-generate-an-md-file-from-a-rmarkdown-file-containing-an-htmlwidget gives the same error as shown in my original post.
Does this prompt any thoughts that might lead to a solution to my problem?
The university IT people were able to solve my problem by uninstalling R and RStudio from the network drive and installing it on the C: drive and I am now able to knit successfully.

aerender ERROR: No render settings template was found with the given name

I'm trying to run aerender.exe from command-line using
aerender.exe -project /path/to/my/project -comp "Intro" -s 1 -e 10 -RStemplate "Multi-Machine Settings" -OMtemplate "Multi-Machine Sequence"
I actually copy/pasted this command and tweaked it slightly to fit my .aep file and composition name.
However, running it gives me
aerender ERROR: No render settings template was found with the given name.
I've tried running in admin mode to no avail.
I simply dont get it. They're default templates and even Adobe states them on their site (https://helpx.adobe.com/after-effects/using/automated-rendering-network-rendering.html).
Why do I get this error?
Can anyone using after effects confirm this?
I found the problem!
I'm using a German version of After Effects CS6.
The template names are translated into German, too.
So the above command should look like:
aerender.exe -project /path/to/my/project -comp "Intro" -s 1 -e 10 -RStemplate "Multi-Machine Settings" -OMtemplate "Sequenz für mehrere Rechner"

C++ program cannot find latex command with system() function call

I am writing a C++ program which has to automatically generate some data to be used by students in an integrated exercise. I have already exported this data to .tex files and would also like the C++ program to be able to compile these tex files automatically.
Usually I would compile tex files from the command line by doing the following:
$ latex file.tex
$ latex file.tex
$ dvipdf file.dvi
So I tried doing the following in my C++ code (directory and filename are both strings):
//Move to the location where I created the files
string mycommand = "cd ";
mycommand += directory;
system(mycommand.c_str());
//Compile latex
mycommand = "latex " + filename + "_main.tex";
system(mycommand.c_str());
system(mycommand.c_str());
//Create .pdf
mycommand = "dvipdf " + filename + "_main.dvi";
system(mycommand.c_str());
Which then produces the following error message on the terminal output:
sh: latex: command not found
sh: latex: command not found
sh: dvipdf: command not found
I have searched this online but I have failed to find a solution for this problem, though I believe it is likely to be something very simple.
I am working on OSX and have the following version of latex installed:
pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012)
kpathsea version 6.1.0
All help is greatly appreciated!
First, the path to the programs latex and dvipdf needs to be in your PATH environment variable.
Second, the calls of the shell via system are totally independent (in fact a new instance of the shell is started each time). So if you switch the directory in one, this does not affect the others. Switch instead the current directory of your program via:
chdir(directory.c_str())
You need for this
#include <cunistd>
using namespace std;
at the beginning of the file.
Please note that system calls with command lines depending on input parameters can be easily exploited to run arbitrary commands if the parameters (in your case the filename) are not carefully checked. As you do not have quotes, the program fails if there are e.g. whitespaces in the filename.

System Call C++ with Weka

I'm writing a C++ project that will occasionally use a system call to Weka to get some machine learning information. First I'd like to ensure that the training model (training.model) is up to date. So, at the beginning of main, I call:
system("\"java weka.classifiers.trees.J48 -t ML_data.arff -d training.model\"");
That gives Error: could not find or load main class weka.classifiers.trees.J48. I know what that means, so I moved the entire Weka project folder, entitled Weka-3-6, to the directory in which my project is found. So then I tried:
system("\"java \Weka-3-6\\weka.classifiers.trees.J48 -t ML_data.arff -d training.model\"");
But that returns Error: could not find or load Weka-3-6\weka.classifiers.trees.J48.
I feel like I'm in the right neighborhood, but I can't get the slashes right, and I'd prefer not to mess with absolute paths because the folders have spaces and that makes it even messier. Any ideas? Help is greatly appreciated.
Open a terminal/cmd prompt and try to run your command in your terminal/cmd prompt. Following is an example cmd batch script for windows. Your problem is most likely java classpath settings not weka problem. If you succeed in following command, then try your command with again in c++.
SET WEKA_HOME=C:\Program Files\Weka-3-7
SET CLASSPATH=%CLASPATH%;%WEKA_HOME%\weka.jar
SET HEAP_OPTION=-Xms4096m -Xmx8192m
SET JAVA_COMMAND=java %HEAP_OPTION%
%JAVA_COMMAND% weka.core.SystemInfo

How to use cppcheck's inline suppression filter option for C++ code?

I would like to use Cppcheck for static code analysis of my C++ code. I learned that I can suppress some kind of warnings with --inline-suppr command.
However, I can't find what "suppressed_error_id" I should put in the comment:
// cppcheck-suppress "suppressed_error_id"
You can change the output template to display the error id from the command line, which is quite neat.
For a Visual Studio format output with error id displayed, add this to your command line:
--template "{file}({line}): {severity} ({id}): {message}"
This will produce output something like this:
s:\src\jpeg.cpp(123): error (bufferAccessOutOfBounds): Buffer access out-of-bounds: abRY
Which you can then suppress by adding the line:
// cppcheck-suppress bufferAccessOutOfBounds
To the previous line in the source file.
According to the cppcheck help:
The error id is the id that you want
to suppress. The easiest way to get it
is to use the --xml command line flag.
Copy and paste the id string from the
xml output.
So run cppcheck against some code that contains the error with the --xml flag, and then look in the generated XML file to find its name.
According to the cppcheck man page, you can use the --template option to change the default output to include the id, e.g.
cppcheck /the/src/file --template='{file}:{line},{severity},{id},{message}'
If you're using the GUI, you can right click on the message that you want to suppress to pop up a menu. Select "Copy message id". Paste the message id into your code in place of "suppressed_error_id".