Aruco Marker Generating Visual studio 2019 vc16 - c++

I am trying to generate aruco marker using Visual Studio vc16 and opencv 4.70 lib with opencv_contrib.4. After building the libraries, i tried to run a short simple program for generating aruco marker and I got an error that I added after code.
the code that I am using:
#include <opencv2/highgui.hpp>
#include <opencv2/aruco.hpp>
using namespace cv;
namespace {
const char* about = "Create an ArUco marker image";
const char* keys =
"{#outfile |<none> | Output image }"
"{d | | dictionary: DICT_4X4_50=0, DICT_4X4_100=1, DICT_4X4_250=2,"
"DICT_4X4_1000=3, DICT_5X5_50=4, DICT_5X5_100=5, DICT_5X5_250=6, DICT_5X5_1000=7, "
"DICT_6X6_50=8, DICT_6X6_100=9, DICT_6X6_250=10, DICT_6X6_1000=11, DICT_7X7_50=12,"
"DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15, DICT_ARUCO_ORIGINAL = 16}"
"{id | | Marker id in the dictionary }"
"{ms | 200 | Marker size in pixels }"
"{bb | 1 | Number of bits in marker borders }"
"{si | false | show generated image }";
}
int main(int argc, char* argv[]) {
CommandLineParser parser(argc, argv, keys);
parser.about(about);
if (argc < 4) {
parser.printMessage();
return 0;
}
int dictionaryId = parser.get<int>("d");
int markerId = parser.get<int>("id");
int borderBits = parser.get<int>("bb");
int markerSize = parser.get<int>("ms");
bool showImage = parser.get<bool>("si");
String out = parser.get<String>(0);
if (!parser.check()) {
parser.printErrors();
return 0;
}
Ptr<aruco::Dictionary> dictionary =
aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
Mat markerImg;
aruco::drawMarker(dictionary, markerId, markerSize, markerImg, borderBits);
if (showImage) {
imshow("marker", markerImg);
waitKey(0);
}
imwrite(out, markerImg);
return 0;
}
the error:
> Build started... 1>------ Build started: Project: TESTOPENCV,
> Configuration: Release x64 ------ 1>main.cpp error C2039:
> 'PREDEFINED_DICTIONARY_NAME': is not a member of 'cv::aruco'
> 1>C:\OpenCVLIB\install\include\opencv2\aruco.hpp(11): message : see
> declaration of 'cv::aruco' error C3861: 'PREDEFINED_DICTIONARY_NAME':
> identifier not found
> 1>C:\Users\ilyas\source\repos\TESTOPENCV\main.cpp(47,12): error C2039:
> 'drawMarker': is not a member of 'cv::aruco'
> 1>C:\OpenCVLIB\install\include\opencv2\aruco.hpp(11): message : see
> declaration of 'cv::aruco' 1 error C3861: 'drawMarker': identifier not
> found 1>Done building project "TESTOPENCV.vcxproj" -- FAILED.
> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am new to Arcuo marker, so I have no idea what do and what to change and to what. Any help would be really appreciated!
I tried looking it up, but could not find any answer on the internet. It says that Arcuo marker library has been changed but I am not sure what changed to what.

Related

PerforceChangeList : error : No matching clients for root

I am syncing and building a project using jenkins with msbuild tool, but I keep getting this error everytime I run the build, either in VS or through Jenkins. I honestly have no idea what it means and I have not found any information on internet. I have another very similar project which runs fine. Any help or what to start checking it would be much appreciated as I have delete and set the job from scratch with the same result. This is the output I get from jenkins:
"C:\Users\User\.jenkins\workspace\Age_3_DE\Source\Age3DE.sln" (default target) (1) ->
"C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj" (default target) (2) ->
(PreBuildEvent target) ->
PerforceChangeList : error : No matching clients for root=C:\Users\User\.jenkins\workspace\Age_3_DE\ [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(128,5): error MSB3073: The command "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\..\Scripts\PerforceChangeList.bat age3 "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\PerforceVersion.inc" "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\resource_version.h" [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(128,5): error MSB3073: :VCEnd" exited with code -1. [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
27 Warning(s)
2 Error(s)
resource_version.h file:
#pragma once
#define VERSION_MAJOR 100
#define VERSION_MINOR 10
#define VERSION_BUILD 0
#define VERSION_STRING "100.10.0.0"
and PerforceVersion.inc:
#pragma once
namespace PerforceInfo {
const char* gChangeList = "00000";
const char* gVersionString = "100.10.0.0";
const char* gUserName = "";
const char* gClientName = "";
const char* gClientHost = "";
const char* gClientRoot = "";
const char* gClientStream = "";
}
Here is an image with the exactly error and the line where the error happens from VS Error

OpenCV 3 error 'CV_FOURCC': identifier not found

Just built OpenCV 3 on PC with Visual Studio 2013 and now I'm trying code but sadly I can't figure out what's wrong?
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main() {
VideoCapture vcap(0);
if (!vcap.isOpened()) {
cout << "Error opening video stream or file" << endl;
return -1;
}
int frame_width = vcap.get(cv::CAP_PROP_FRAME_WIDTH);
int frame_height = vcap.get(cv::CAP_PROP_FRAME_HEIGHT);
VideoWriter video("out.avi", CV_FOURCC('M', 'J', 'P', 'G'), 10, Size(frame_width, frame_height), true);
for (;;) {
Mat frame;
vcap >> frame;
video.write(frame);
imshow("Frame", frame);
char c = (char)waitKey(33);
if (c == 27) break;
}
return 0;
1>------ Build started: Project: ConsoleApplication12, Configuration: Release x64 ------
1> Source.cpp
1>Source.cpp(21): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>Source.cpp(22): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>Source.cpp(23): error C3861: 'CV_FOURCC': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Couldn't figure out with what I have to replace "CV_FOURCC".
edited:
int frame_width = vcap.get(cv::CAP_PROP_FRAME_WIDTH);
int frame_height = vcap.get(cv::CAP_PROP_FRAME_HEIGHT);
int codec = cv::VideoWriter::fourcc('M', 'J', 'P', 'G');
VideoWriter video("out.avi", codec, 10, Size(frame_width, frame_height), true);
looks like this has changed in later versions of OpenCV to cv::VideoWriter::fourcc(...) where ... is the four-character-comma-separated list.
More information here for OpenCV 3.4: https://docs.opencv.org/3.4/dd/d9e/classcv_1_1VideoWriter.html#afec93f94dc6c0b3e28f4dd153bc5a7f0
I used bad OpenCV source to build my libraries.

OpenCV 3.2.0, Visual Studio 2015, Windows 7

I installed the pre-built libraries OpenCV 3.2.0 on Windows 7 following the instructions here and I am encountering errors when trying to use them in Visual Studio 2015.
The variable OPENCV_DIR is set correctly:
C:\>echo %OPENCV_DIR%
C:\OpenCV\Build\x64\vc14
C:\>dir %OPENCV_DIR%
Le volume dans le lecteur C s'appelle OS
Le numéro de série du volume est 1234-ABCD
Répertoire de C:\OpenCV\Build\x64\vc14
27/01/2017 17:10 <REP> .
27/01/2017 17:10 <REP> ..
27/01/2017 17:11 <REP> bin
27/01/2017 17:10 <REP> lib
0 fichier(s) 0 octets
4 Rép(s) 19 236 450 304 octets libres
C:\>
And the rules for the project are like there
With the libraries specified as
opencv_calib3d320d.lib
opencv_core320d.lib
opencv_features2d320d.lib
opencv_flann320d.lib
opencv_highgui320d.lib
opencv_imgcodecs320d.lib
opencv_imgproc320d.lib
opencv_ml320d.lib
opencv_objdetect320d.lib
opencv_photo320d.lib
opencv_shape320d.lib
opencv_stitching320d.lib
opencv_superres320d.lib
opencv_ts320d.lib
opencv_video320d.lib
opencv_videoio320d.lib
opencv_videostab320d.lib
But when I try to compile the basic test project written there
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], IMREAD_COLOR); // Read the file
if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
I get the error
1>------ Build started: Project: ImageCorrection, Configuration: Debug x64 ------
1> test.cpp
1>LINK : fatal error LNK1104: cannot open file 'opencv_calib3d320d.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am really new to compilation and linking on Windows and Visual Studio (I am used to g++ on Linux) so I really have no idea of what I am doing wrong here.
I think that it might have something to do with the dynamic linking, but I do not know neither how to investigate nor how to solve it.
Ant help is most appreciated! :D
OpenCV 3.2 prebuild binaries have just the world lib:
opencv_world320.lib for release
opencv_world320d.lib for debug
That's all you need to link.

Code Analysis does not work in VS 2010 - Code Analysis Complete -- 0 error(s), 0 warning(s)

I'm trying to use Code Analysis in VS2010, but it's not working.
My sample appl:
#include "stdafx.h"
#include <malloc.h>
int getj() {
return 10;
}
int a(int *n) {
int b = *n;
int c = 1/b;
return c;
}
int _tmain(int argc, _TCHAR* argv[]) {
int *a;
a = (int *)malloc(10*sizeof(int));
if( a ) {
free( a );
a[0] = 12;
a[getj()] = 12;
}
return 0;
}
To start analysis, I using "Analyze-> Run Code Analysis on ...."
and logs :
1>------ Rebuild All started: Project: test1, Configuration: Debug Win32 ------
1>Build started 2013-07-01 17:45:40.
1>_PrepareForClean:
1> Deleting file "Debug\test1.lastbuildstate".
1>InitializeBuildStatus:
1> Creating "Debug\test1.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> stdafx.cpp
1> test1.cpp
1>Manifest:
1> Deleting file "Debug\test1.exe.embed.manifest".
1>LinkEmbedManifest:
1> test1.vcxproj -> D:\test1\Debug\test1.exe
1>RunCodeAnalysis:
1> Running Code Analysis...
1> **Code Analysis Complete -- 0 error(s), 0 warning(s)**
1>FinalizeBuildStatus:
1> Deleting file "Debug\test1.unsuccessfulbuild".
1> Touching "Debug\test1.lastbuildstate".
1>![enter image description here][1]
1>Build succeeded.
1>
1>Time Elapsed 00:00:03.40
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Config:
On the "Property page", I have turned on:
-Enabled Code Analysis ob Build (defines....
-Enabled Code Analysis for C/C++ on Build
-Supress results from ...
-and Ruls Set ->AllRules
My question is what I'm doing wrong, or how to run code analysis in VS2010 ?
thanks

Compiling Mathlink Code in Visual Studio 2010 Express LNK2019 Error

I'm attempting to compile a simple C file for use with Mathematica. (Note: I did follow the rest of the instructions, creating the empty addtwotm.c file and adding addtwo.tm)
#include "mathlink.h"
extern int addtwo( int i, int j);
int addtwo( int i, int j)
{
return i+j;
}
#if WINDOWS_MATHLINK
#if __BORLANDC__
#pragma argsused
#endif
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
{
char buff[512];
char FAR * buff_start = buff;
char FAR * argv[32];
char FAR * FAR * argv_end = argv + 32;
hinstPrevious = hinstPrevious; /* suppress warning */
if( !MLInitializeIcon( hinstCurrent, nCmdShow)) return 1;
MLScanString( argv, &argv_end, &lpszCmdLine, &buff_start);
return MLMain( (int)(argv_end - argv), argv);
}
#else
int main(int argc, char* argv[])
{
return MLMain(argc, argv);
}
#endif
However, on build, I get this output:
1>------ Build started: Project: addtwo, Configuration: Debug Win32 ------
1> Performing Custom Build Tools
1> on "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VC\bin\mprep.exe" "" -o "D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\addtwo\..\addtwotm.c"
1>addtwo.obj : error LNK2019: unresolved external symbol _MLMain referenced in function _WinMain#16
1>addtwo.obj : error LNK2019: unresolved external symbol _MLInitializeIcon referenced in function _WinMain#16
1>D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\Debug\addtwo.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've followed all provided instructions from Wolfram's MathLink Developer Guide, and made sure to add "ml32i3m.lib" to Linker>Input>Additional Dependencies. Supposedly the ml32/ml64 lib files contain the information for MlMain. Any help is appreciated :)