#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <cvblob.h>
#include <iostream>
using std::string;
#include <cstdlib>
class ImageProcessing
{
// ImageProcessing* ImgPtr;
private:
IplImage *img0, *img1;
IplImage* ReducImg;
IplImage* ReducImgColor;
CvSize imgSize;
CvPoint C1,C2;
public:
friend class CarVideoHandler;
ImageProcessing(void);
~ImageProcessing(void);
void checkZone(CvTracks::const_iterator ot, double position1, double position2, int **T1,int **T2,int **T3,int **T4, int &numCars, int dire, int p, string type,string dc, string dp);
void checkZoneOneLine(CvTracks::const_iterator ot, double position1, int **T1,int **T2, int &numCars, int dire, int p, string type, int **distance,string dc, string dp);
int CarOrPerson(long area, float wh, CvTracks::const_iterator ot, int *labelTrack[]);
string idTrackCarPerson(IplImage *colourImage1, int *labelTrack[], CvBlobs::const_iterator it, CvTracks::const_iterator ot, int percent, double lin, double position1, double position2, CvFont font, char* wow, int **T1, int **T2, int **T3, int **T4, int &numCars, int &numPersons, int *Xx, int *Xy, int *Yx, int *Yy, int *dire, int n, int m, int p,string dc, string dp);
};
Compiler is throwing error 'CvTrackers' has not been declared when I compile. The same function when I declare it outside the class the compiler was not throwing any error. But when I make it class member the compiler is throwing error. Guys help me to resolve this error.
Ok so I looked through the CVBlobs.h file on Github and the iterator used in the for loops in the relevant struct is CvTracks::iterator. I would suggest trying to remove the const_ and see if that works.
Related
error: "prototype for WeatherForecaster::WeatherForecaster(std::all of the variables) does not match any class in WeatherForecaster"
I'm out of ideas on how to avoid this. My main code has nothing to do with the error btw.
MOST RECENT ERROR, THE REST FIXED. I now get the error in main "no matching function to call to WeatherForecast::WeatherForecast()". After I create the variable wf WeatherForecast.
Source:
#include "WeatherForecaster.h" //header being included
#include<iostream>
using namespace std;
//error comes here
WeatherForecaster::WeatherForecaster(string d, string fd, int h, int l,
int hum,int avgw, string avgwd, int maxw, string maxwd, double p)
{
string day=d;
string forecastDay=fd;
int highTemp=h;
int lowTemp =l;
int humidity=hum;
int avgWind= avgw;
string avgWindDir=avgwd;
int maxWind=maxw;
string maxWindDir= maxwd;
double recip=p;
}
WeatherForecaster::~WeatherForecaster(){
//dtor
};//end of block of source code
Header: I am making such a simple mistake, I'm just not sure what it exactly is.
#ifndef WEATHERFORECASTER_H
#define WEATHERFORECASTER_H
#include <iostream>
using namespace std;
//does my code have a problem with how it interacts with this struct?
struct ForecastDay{
std::string day;
std::string forecastDay;
int highTemp;
int lowTemp;
int humidity;
int avgWind;
std::string avgWindDir;
int maxWind;
std::string maxWindDir;
double precip;
};
class WeatherForecaster
{
public://most recent error ") expected before 'd'"
WeatherForecaster(string d, string fd, int h, int l,
int hum,int avgw, string avgwd, int maxw, string maxwd, double p);
~WeatherForecaster();
void addDayToData(ForecastDay);
void printDaysInData();
void printForecastForDay(std::string);
void printFourDayForecast(std::string);
double calculateTotalPrecipitation();
void printLastDayItRained();
void printLastDayAboveTemperature(int); //argument is the
temperature
void printTemperatureForecastDifference(std::string);
void printPredictedVsActualRainfall(int);
std::string getFirstDayInData();
std::string getLastDayInData();
protected:
private:
int arrayLength;
int index;
ForecastDay yearData[984];
};
#endif // WEATHERFORECASTER_H
Where is your declaration of constructor taking these parameter (string d, string fd, int h, int l, int hum,int avgw, string avgwd, int maxw, string maxwd, double p) in the header?
It is exactly as the error message states: you need to add a prototype for "WeatherForecaster(string d, string fd, int h, int l,int hum,int avgw, string avgwd, int maxw, string maxwd, double p)" in your WeatherForecaster class.
Source File:
#include "WeatherForecaster.h"
#include <iostream>
using namespace std;
WeatherForecaster::WeatherForecaster(string d, string fd, int h, int l, int hum,int avgw, string avgwd, int maxw, string maxwd, double p){
string day=d;
string forecastDay=fd;
int highTemp=h;
int lowTemp =l;
int humidity=hum;
int avgWind= avgw;
string avgWindDir=avgwd;
int maxWind=maxw;
string maxWindDir= maxwd;
double recip=p;
}
WeatherForecaster::WeatherForecaster(){
//dtor
}
void AddDaytoData(ForecastDay){
}
Header File:
#ifndef WEATHERFORECASTER_H
#define WEATHERFORECASTER_H
#include <iostream>
using namespace std;
struct ForecastDay{
std::string day;
std::string forecastDay;
int highTemp;
int lowTemp;
int humidity;
int avgWind;
std::string avgWindDir;
int maxWind;
std::string maxWindDir;
double precip;
};
class WeatherForecaster
{
public:
WeatherForecaster(string, string, int, int,
int,int, string, int, string , double );
WeatherForecaster();
void addDayToData(ForecastDay);
void printDaysInData(); //prints the unique dates in the data
void printForecastForDay(std::string);
void printFourDayForecast(std::string);
double calculateTotalPrecipitation();
void printLastDayItRained();
void printLastDayAboveTemperature(int);
void printTemperatureForecastDifference(std::string);
void printPredictedVsActualRainfall(int);
std::string getFirstDayInData();
std::string getLastDayInData();
protected:
private:
int arrayLength;
int index;
ForecastDay yearData[984]; //data for each day
};
#endif // WEATHERFORECASTER_H
ERROR: My error happens when I declare try to reach a function in my source file after declaring an instance of the class Weather Function.
ex:
WeatherForecaster wf;
wf.AddDayToData();
//undefined reference to 'WeatherForecaster::AddDaytoData'
I am not entirely sure where the lack of referencing is happening, also I have the header included in main, as well as all other relevant additions.
Edit: I added a function as an example
In your cpp file you need to scope your member function definition
WeatherForecaster::AddDayToData(ForecastDay)
instead of
AddDayToData(ForecastDay)
Also in your call you must pass an argument since it's not optional
I have a header file Algo.h. It has the following content:
#include <iostream>
#include <fstream>
#include <math.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
//some static functions
// ...
template <class Type> class Algo{
int
public:
Algo(int size, int num, int plth, int theN, float** theAg, int theLN,
float* theIn, float theeEps = 1E-3, float theEpsilonLR = 1E-3,
int theCycle = 30, bool DebInf = false, int theT = -1, int** theX = 0,
const char* theFileName = 0, const char* theFileNameChar = 0);
~Algo();
//some methods
//...
};
//Constructor
template <class Type> Algo<Type>::Algo(int size, int num, int plth, int theN, float** theAg, int theLN,
float* theIn, float theeEps = 1E-3, float theEpsilonLR = 1E-3,
int theCycle = 30, bool DebInf = false, int theT = -1, int** theX = 0,
const char* theFileName = 0, const char* theFileNameChar = 0){
//...
}
// ...
Then I'd like to usel it in main.cpp:
#include "Algo.h"
#include <float.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
Algo<int>* construct1(const int & rt, float** & rm); //error: Algo is not a template
Algo<int>* construct2(const int & rte, float** & rm, Algo<int>* & the1, const bool & rob1); //error: Algo is not a template
//...
int main(){
//...
return 0;
}
It seems that everything should work fine, but I always get this error:
Algo is not a template.
Do you have any ideas how to fix it?
there is "int" which should not be there in your code. delete it, please.
template <class Type> class Algo{
int // here should be deleted
public:
...
constructor of Algo has many default params, but when you define this function, these default params should not be set value in param-list. you can make the constructor definition as follows:
template <class Type> Algo<Type>::Algo(int size, int num, int plth, int theN, float** theAg, int theLN, float* theIn, float theeEps, float theEpsilonLR, int theCycle, bool DebInf, int theT, int** theX, const char* theFileName, const char* theFileNameChar)
{
//...
}
do these 2 fixs, it will works.( I have try it on my computer~ )
I don't think this is the only problem, but pay attention to how you attempt to use it.
The constructor:
Algo(int size, int num, int plth, int theN, float** theAg, int theLN,
float* theIn, float theeEps = 1E-3, float theEpsilonLR = 1E-3,
int theCycle = 30, bool DebInf = false, int theT = -1, int** theX = 0,
const char* theFileName = 0, const char* theFileNameChar = 0);
Has many parameters. The first 7 are required, the remainder have default values and are optional. However, when you try and instantiate an instance:
Algo<int>* construct1(const int & rt, float** & rm); //error: Algo is not a template
Algo<int>* construct2(const int & rte, float** & rm, Algo<int>* & the1, const bool & rob1); //error: Algo is not a template
You are passing either 2, or 4 parameters. There is no matching overload.
You need to provide at least the first 7 parameters.
I have been working to create an Arduino library to control a touchscreen. My library builds off of pre-existing libraries written to interface with the display & touch controllers.
Here is the constructor that I have been working on:
Display.cpp
Display::Display(int displayCSPin, int displayDCPin, int touchCSPin,
int newBacklightPin, int newRotation, int newBrightness)
: Adafruit_HX8357(displayCSPin, displayDCPin, -1),
Adafruit_STMPE610(touchCSPin)
{
//Initialize display
}
Display.h
#ifndef DISPLAY_H_
#define DISPLAY_H_
#include "arduino.h"
#include "Adafruit_GFX.h"
#include "Adafruit_HX8357.h"
#include "Adafruit_STMPE610.h"
class Display : public Adafruit_HX8357, Adafruit_STMPE610 {
public:
Display(int displayCSPin, int displayDCPin, int touchCSPin,
int newBacklightPin, int newRotation, int newBrightness);
};
Whenever I try to compile, the compiler ignores the variables in the base class constructors, and tries to call a default constructor with no variables:
error: no matching function for call to 'Adafruit_HX8357::Adafruit_HX8357()'
I have tried my best to solve this problem, but have not had any success.
Any and all help is greatly appreciated!
Here is the raw code:
Display.cpp
#include "Display.h"
Display::Display(int displayCSPin, int displayDCPin, int touchCSPin, int newBacklightPin, int newRotation, int newBrightness) : Adafruit_HX8357(displayCSPin, displayDCPin, -1), Adafruit_STMPE610(touchCSPin)
{
// tft = Adafruit_HX8357(displayCSPin, displayDCPin, -1);
//ts = Adafruit_STMPE610(touchCSPin);
tft.begin(HX8357D);
ts.begin();
tft.setRotation(newRotation);
backlightPin = newBacklightPin;
pinMode(backlightPin, OUTPUT);
rotation = newRotation;
backgroundColor = HX8357_BLACK;
brightness = newBrightness;
}
Display.h
#ifndef DISPLAY_H_
#define DISPLAY_H_
#include "arduino.h"
#include "Adafruit_GFX.h"
#include "Adafruit_HX8357.h"
#include "Adafruit_STMPE610.h"
class Display : public Adafruit_HX8357, public Adafruit_STMPE610 {
public:
Display(int displayCSPin, int displayDCPin, int touchCSPin, int newBacklightPin, int newRotation, int newBrightness);
void wake();
void sleep();
bool isAwake();
void setBackGroundColor(int newColor);
int getBackgroundColor();
void setBrightness(int newBrightness);
int getBrightness();
void setRotation(int newRotation);
int getRotation();
bool isTouched();
Adafruit_HX8357 tft;
Adafruit_STMPE610 ts;
int backgroundColor;
private:
int brightness;
int rotation;
int backlightPin;
bool awake;
bool touched;
TS_Point p;
};
Look at the actual constructors available for Adafruit_HX8357 and Adafruit_STMPE610:
Adafruit_HX8357(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
int8_t _RST, int8_t _MISO);
Adafruit_HX8357(int8_t _CS, int8_t _DC, int8_t _RST = -1);
Adafruit_STMPE610(uint8_t cspin, uint8_t mosipin, uint8_t misopin, uint8_t clkpin);
Adafruit_STMPE610(uint8_t cs);
Adafruit_STMPE610(void);
Your Display constructor is trying to call the second constructor of each class. However, Display is passing int values where int8_t and uint8_t values are expected. It sounds like maybe your compiler is not performing implicit conversions from int to (u)int8_t, so try using explicit conversions to force it:
Display::Display(int displayCSPin, int displayDCPin, int touchCSPin, int newBacklightPin, int newRotation, int newBrightness)
: Adafruit_HX8357((int8_t)displayCSPin, (int8_t)displayDCPin, -1),
Adafruit_STMPE610((uint8_t)touchCSPin)
{
//Initialize display
}
Otherwise, change you Display constructor parameters to use int8_t and uint8_t instead of int:
Display::Display(int8_t displayCSPin, int8_t displayDCPin, uint8_t touchCSPin, int newBacklightPin, int newRotation, int newBrightness)
: Adafruit_HX8357(displayCSPin, displayDCPin, -1),
Adafruit_STMPE610(touchCSPin)
{
//Initialize display
}
I am trying to compile a library, when running make I get many of the following errors:
error: conflicting declaration ‘int x’
error: ‘x’ has a previous declaration as ‘Text* x’
Here is the code:
.
.
.
class Text;
class Code {
private:
std::vector<std::string> *tokens;
std::vector<std::string> *compounds;
std::vector<std::string> *compound_xml;
std::vector<std::string> *compound_xml_action;
void set_helper(Text *x, int a, int b, int c, std::string field, std::string value);
std::string itoa(int x);
public:
Code();
~Code();
int analyse_code(Text *x, std::string c, int x, int y, int z);
int print(Text *x, std::string c, int x, int y, int z);
int is_class(Text *x, std::string c, int x, int y, int z);
int is_class2(Text *x, std::string c, int x, int y, int z);
int not_class(Text *x, std::string c, int x, int y, int z);
.
.
.
so in analyse_code function\method, should I convert int x to int a or int wtv or is it smth else causing the error?
since the author of the library has used Text* x and int x in many functions, I thought maybe he knows what he's doing and pointers can be int, or am I wrong thinking he knows what he is doing?
Irrelevant: The library is Adso, a Chinese text analysis engine.
You have two parameters named 'x' in declaration like that:
int not_class(Text *x, std::string c, int x, int y, int z);
Name one of them something else. For example:
int not_class(Text *txt, std::string c, int x, int y, int z);
The author was not very good, so beware other errors too.
the problem is not only in analyse_code but in all the private functions. if you have the source code (.c file) I would have check it there also.
anyway you should change the Text *x to anything else such as Text *text