I am using opencv's cv::ml::LogisticRegression class and have serialized it and saved it to file using the cv::Algorithm::save method, and am trying to load the file back into a Ptr<LogisticRegression> using cv::ml::LogisticRegression::load, as described in the documentation, my save code looks like this:
Ptr<cv::ml::LogisticRegression> logisReg = logisticRegression(features_train, labels_train);
logisReg->save("mFileName");
And load code (different place)
Ptr<cv::ml::LogisticRegression> logisReg = cv::ml::LogisticRegression::load("mFileName", "Logisitic Regression Classifier");
The save code works fine, and the serialized file content makes sense (plain text). However, when I tried to compile the load it, I got this error:
main.cpp:97:5: error: no matching function for call to 'load'
cv::ml::LogisticRegression::load("logisReg.auracle", "Logisitic Regression Classifier");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/opt/opencv3/include/opencv2/core.hpp:3074:44: note: candidate template ignored: couldn't infer template argument '_Tp'
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
^
1 error generated.
make: *** [main.o] Error 1
The documentation you give is of version 3.2.0-dev, which has function:
static Ptr<LogisticRegression> load(const String &filepath, const String &nodeName=String())
but version before 3.1 only has an inherited template function:
template<typename _Tp >
static Ptr<_Tp> load (const String &filename, const String &objname=String())
I guess you are using opencv lib version before 3.1, try instantiate the template function explicitly:
load<LogisticRegression>()
Related
I am programming for the ESP32 (a sort of Arduino like chip). However, to easier/faster find compiler errors/warnings and later make a sort of virtualization on the PC, I like to compile the code also on a PC (using Visual Studio).
However, I cannot get the following code to compile on a PC (while it compiles in the Arduino IDE for ESP32):
server.on("/", HTTP_GET, [](AsyncWebServerRequest* request)
{
request->send_P(200, "text/html", textBuffer, Processor);
});
The errors I get are:
Severity Code Description Project File Line Suppression State
Error (active) E0413 no suitable conversion function from "lambda []void (AsyncWebServerRequest *request)->void" to "AsyncWebServerRequest *" exists RelayBox C:\Users\miche\source\repos\RelayBox2\RelayBox\RelayBox\RelayBoxServer.cpp 203
Error C2664 'void AsyncWebServer::on(const char *,int,AsyncWebServerRequest *)': cannot convert argument 3 from 'RelayBoxServer::Send::<lambda_6ffcff35888ca3a1f1d7d541e1edeba3>' to 'AsyncWebServerRequest *' RelayBox C:\Users\miche\source\repos\RelayBox2\RelayBox\RelayBox\RelayBoxServer.cpp 206
The code is based on the ESP32 library at https://github.com/me-no-dev/ESPAsyncWebServer/blob/master/src/ESPAsyncWebServer.h
And the 'stub' classes I created using library above but simplified for my project, with '...' as irrelevant code:
class AsyncWebServer
{
...
void on(const char* something, int httpGet, AsyncWebServerRequest* function);
...
}
#define HTTP_GET 100
class AsyncWebServerRequest
{
public:
void send_P(int port, const char* textHmlt, STRING text, ProcessorHandlerFunction function);
};
class ArduinoStringStub : public std::string
{
...
}
How can I fix the argument type conversion compiler errors in this method using a lambda function?
I've checked your reference github, it seems that the origin AsyncWebServer class has such signature:
AsyncCallbackWebHandler& on(const char* uri, WebRequestMethodComposite method, ArRequestHandlerFunction onRequest);
And ArRequestHandlerFunction is actually:
typedef std::function<void(AsyncWebServerRequest *request)> ArRequestHandlerFunction;
So it seems to be that the stub/mock AsyncWebServer you create should not take AsyncWebServerRequest* but ArRequestHandlerFunction as the on method's last parameter, corresponding with the original code.
The function prototype in the class .h includes 2 arguments, and the function in the class .cpp includes the same 2 arguments, but the compiler pretends it only has 1 (ignoring the second) and prints the following error:
void list::swap(const string[] from, const string[] to)
^~~~
list.cpp:103:6: error: prototype for ‘void list::swap(const string*)’ does not match any in class ‘list’
void list::swap(const string[] from, const string[] to)
^~~~
In file included from list.cpp:6:0:
list.h:83:10: error: candidate is: void list::swap(const string*, const string*)
void swap(const string[], const string[]);
^~~~
I thought maybe it was a memory issue at first, but I have 26 GB of RAM and only 3GB being used by the web browser. I've tried refreshing and restarting my computer. You can see for yourself with this truncated code:
https://onlinegdb.com/-L_eUQTzY
The brackets have to come after the name:
void list::swap(const string from[], const string to[])
So it's assuming the first const string[] is the passed argument and ignoring everything else on that line because it expects either a ',' or '...' after the arguments name before something else is written.
I have been working with NodeMCU for 1 week but suddenly yesterday, while compiling NodeMCU again, as usual, it is showing error during compiling and not uploading the code. Please help me get out of it.
This is the error coming
Arduino: 1.8.12 (Windows 8.1), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
In file included from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkApiArduino.h:14:0,
from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkSimpleEsp8266.h:24,
from C:\Users\Govind\Desktop\Stepper_Motor_Joystick_2.21\Stepper_Motor_Joystick_2.21.ino:3:
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkApi.h: In instantiation of 'void BlynkApi<Proto>::syncVirtual(Args ...) [with Args = {}; Proto = BlynkProtocol<BlynkArduinoClientGen<Client> >]':
C:\Users\Govind\Desktop\Stepper_Motor_Joystick_2.21\Stepper_Motor_Joystick_2.21.ino:69:25: required from here
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkApi.h:143:9: error: no matching function for call to 'BlynkParam::add_multi()'
cmd.add_multi(pins...);
^
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkApi.h:143:9: note: candidates are:
In file included from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkApi.h:16:0,
from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkApiArduino.h:14,
from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkSimpleEsp8266.h:24,
from C:\Users\Govind\Desktop\Stepper_Motor_Joystick_2.21\Stepper_Motor_Joystick_2.21.ino:3:
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkParam.h:111:10: note: template<class T, class ... Args> void BlynkParam::add_multi(T)
void add_multi(T last) {
^
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkParam.h:111:10: note: template argument deduction/substitution failed:
In file included from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkApiArduino.h:14:0,
from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkSimpleEsp8266.h:24,
from C:\Users\Govind\Desktop\Stepper_Motor_Joystick_2.21\Stepper_Motor_Joystick_2.21.ino:3:
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkApi.h:143:9: note: candidate expects 1 argument, 0 provided
cmd.add_multi(pins...);
^
In file included from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkApi.h:16:0,
from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkApiArduino.h:14,
from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkSimpleEsp8266.h:24,
from C:\Users\Govind\Desktop\Stepper_Motor_Joystick_2.21\Stepper_Motor_Joystick_2.21.ino:3:
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkParam.h:116:10: note: template<class T, class ... Args> void BlynkParam::add_multi(T, Args ...)
void add_multi(T head, Args... tail) {
^
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkParam.h:116:10: note: template argument deduction/substitution failed:
In file included from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkApiArduino.h:14:0,
from C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/BlynkSimpleEsp8266.h:24,
from C:\Users\Govind\Desktop\Stepper_Motor_Joystick_2.21\Stepper_Motor_Joystick_2.21.ino:3:
C:\Users\Govind\Documents\Arduino\libraries\arduino_238892\src/Blynk/BlynkApi.h:143:9: note: candidate expects 2 arguments, 0 provided
cmd.add_multi(pins...);
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I am currently trying to run stepper motors using the AccelStepper library and Blynk Library and also included Esp8266 Library for connectivity. I am not able to understand the problem
Looks like you called Blynk.syncVirtual() without any arguments. You need to include at least one virtual pin, like this:
Blynk.syncVirtual(V4);
when compiling my own project, I got an error as follows:
myRRT.cc:80:78: error: no matching function for call to ‘ompl::tools::SelfConfig::getDefaultNearestNeighbors(ompl::geometric::RRT*)’
nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Motion *>(this));
^
In file included from /home/htf/Downloads/Active-ORB-SLAM2-octomap/src/myRRT.cc:36:0:
/opt/ros/indigo/include/ompl/tools/config/SelfConfig.h:93:42: note: candidate: template<class _T> static ompl::NearestNeighbors<_T>* ompl::tools::SelfConfig::getDefaultNearestNeighbors(const StateSpacePtr&)
static NearestNeighbors<_T>* getDefaultNearestNeighbors(const base::StateSpacePtr &space)
^
/opt/ros/indigo/include/ompl/tools/config/SelfConfig.h:93:42: note: template argument deduction/substitution failed:
/home/htf/Downloads/Active-ORB-SLAM2-octomap/src/myRRT.cc:80:78: note: cannot convert ‘(ompl::geometric::RRT*)this’ (type ‘ompl::geometric::RRT*’) to type ‘const StateSpacePtr& {aka const boost::shared_ptr<ompl::base::StateSpace>&}’
nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Motion *>(this))
here is a part of my source code,
void ompl::geometric::RRT::setup()
{
Planner::setup();
tools::SelfConfig sc(si_, getName());
sc.configurePlannerRange(maxDistance_);
if (!nn_)
nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Motion *>(this));
nn_->setDistanceFunction(std::bind(&RRT::distanceFunction, this, std::placeholders::_1, std::placeholders::_2));
}
this is one of a example file what I have referedRRT
does anyone have encountered the similar question? i'am new to C++, hope to get some clues. thank you in advance.
ompl::tools::SelfConfig::getDefaultNearestNeighbors(ompl::geometric::RRT*)
so you should modify it like this:
nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Motion>(*this));
maybe motion is the templete and (*this) means you want to call object using (*this)
I am also the green hand. I am not sure.
I am trying to install openCV 2.4.2 on Windows x64 and Netbeans. I have followed the following guide: http://projectsfromhellandmore.blogspot.co.nz/2012/06/opencv-241-netbeans-windows-7-plus.html
When I try to compile the sample code included in the guide I get the following errors for the following blocks of code in the file "include/opencv2/core/operations.hpp" and I have not found any fixes or figured out how to fix it myself:
template<typename _Tp, typename _Base> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
const string& help)
{
//TODO: static assert: _Tp inherits from _Base
addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
error: got 2 template parameters but 1 required
And the second block of code with an error is:
template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Ptr<_Tp>& value, bool readOnly, Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
const string& help)
{
//TODO: static assert: _Tp inherits from Algorithm
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
error: redefinition of ...(the function in the first block of code)
Any help would be greatly appreciated thanks
I faced the same problem with MinGW with opencv2.4.x and later on found out that there was nothing wrong with the operations.hpp file. Instead, the MinGW compiler that i had installed was at fault. I reinstalled the compiler from sourcefourge and it worked. Check your netbeans compiler.
I faced the same problem. the solution to this problem is just comment out the entire template inline function. this function is declared twice just below one another thats why the issue. just comment out one of them.