Skip to content

Commit da7bc43

Browse files
authored
Adding changes for opencv4 compatibility (#4)
1 parent c00b236 commit da7bc43

File tree

7 files changed

+40
-40
lines changed

7 files changed

+40
-40
lines changed

src/karmaLearn/main.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class KarmaLearn: public RFModule
368368
cv::Mat imgMat=toCvMat(img);
369369
imgMat.setTo(cv::Scalar(255));
370370

371-
cv::putText(imgMat,plotItem,cv::Point(250,20),CV_FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
371+
cv::putText(imgMat,plotItem,cv::Point(250,20),cv::FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
372372

373373
double x_min=scalerIn.getLowerBoundIn();
374374
double x_max=scalerIn.getUpperBoundIn();
@@ -383,25 +383,25 @@ class KarmaLearn: public RFModule
383383
{
384384
ostringstream tag; tag.precision(3);
385385
tag<<x_min;
386-
cv::putText(imgMat,tag.str(),cv::Point(10,230),CV_FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
386+
cv::putText(imgMat,tag.str(),cv::Point(10,230),cv::FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
387387
}
388388

389389
{
390390
ostringstream tag; tag.precision(3);
391391
tag<<x_max;
392-
cv::putText(imgMat,tag.str(),cv::Point(280,230),CV_FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
392+
cv::putText(imgMat,tag.str(),cv::Point(280,230),cv::FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
393393
}
394394

395395
{
396396
ostringstream tag; tag.precision(3);
397397
tag<<y_min;
398-
cv::putText(imgMat,tag.str(),cv::Point(10,215),CV_FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
398+
cv::putText(imgMat,tag.str(),cv::Point(10,215),cv::FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
399399
}
400400

401401
{
402402
ostringstream tag; tag.precision(3);
403403
tag<<y_max;
404-
cv::putText(imgMat,tag.str(),cv::Point(10,20),CV_FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
404+
cv::putText(imgMat,tag.str(),cv::Point(10,20),cv::FONT_HERSHEY_SIMPLEX,0.5,cv::Scalar(0));
405405
}
406406

407407
cv::Point pold;

src/karmaManager/include/iCub/module.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct blobsData
4343
int index;
4444
double lenght;
4545
double vdrawError;
46-
CvPoint posistion;
46+
cv::Point posistion;
4747
double bestDistance;
4848
double bestAngle;
4949
std::string name;
@@ -75,7 +75,7 @@ class Manager : public yarp::os::RFModule
7575

7676
std::mutex mutexResources; //mutex for ressources
7777
bool pointGood; //boolean for if got a point location
78-
CvPoint pointLocation; //x and y of the pointed location
78+
cv::Point pointLocation; //x and y of the pointed location
7979
bool init;
8080
yarp::os::Bottle lastBlobs;
8181
yarp::os::Bottle lastTool;
@@ -89,11 +89,11 @@ class Manager : public yarp::os::RFModule
8989
std::map<int, double> randActions;
9090

9191
yarp::os::Bottle getBlobs();
92-
CvPoint getBlobCOG(const yarp::os::Bottle &blobs, const int i);
92+
cv::Point getBlobCOG(const yarp::os::Bottle &blobs, const int i);
9393
double getBlobLenght(const yarp::os::Bottle &blobs, const int i);
9494

95-
bool get3DPosition(const CvPoint &point, yarp::sig::Vector &x);
96-
yarp::os::Bottle findClosestBlob(const yarp::os::Bottle &blobs, const CvPoint &loc);
95+
bool get3DPosition(const cv::Point &point, yarp::sig::Vector &x);
96+
yarp::os::Bottle findClosestBlob(const yarp::os::Bottle &blobs, const cv::Point &loc);
9797
int processHumanCmd(const yarp::os::Bottle &cmd, yarp::os::Bottle &b);
9898
int executeOnLoc(bool shouldTrain);
9999
int executeToolOnLoc();

src/karmaManager/include/iCub/utils.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class Manager; //forward declaration
3333
class ParticleFilter : public yarp::os::BufferedPort<yarp::os::Bottle>
3434
{
3535
protected:
36-
CvPoint loc;
36+
cv::Point loc;
3737
void onRead(yarp::os::Bottle &b);
3838
public:
3939
ParticleFilter();
40-
bool getTraker(CvPoint &loc);
40+
bool getTraker(cv::Point &loc);
4141
};
4242
/**********************************************************/
4343
class SegmentationPoint : public yarp::os::Port
@@ -49,15 +49,15 @@ class SegmentationPoint : public yarp::os::Port
4949
class PointedLocation : public yarp::os::BufferedPort<yarp::os::Bottle>
5050
{
5151
protected:
52-
CvPoint loc;
52+
cv::Point loc;
5353
double rxTime;
5454
double timeout;
5555

5656
void onRead(yarp::os::Bottle &b);
5757

5858
public:
5959
PointedLocation();
60-
bool getLoc(CvPoint &loc);
60+
bool getLoc(cv::Point &loc);
6161
};
6262

6363
#endif

src/karmaManager/src/module.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ Bottle Manager::executeBlobRecog(const string &objName)
445445
closestBlob=findClosestBlob(blobs,pointLocation);
446446
mutexResources.unlock();
447447

448-
CvPoint cog;
448+
cv::Point cog;
449449
cog.x = closestBlob.get(0).asInt();
450450
cog.y = closestBlob.get(1).asInt();
451451

@@ -511,7 +511,7 @@ int Manager::executeToolOnLoc()
511511
closestBlob=findClosestBlob(blobs,pointLocation);
512512
mutexResources.unlock();
513513

514-
CvPoint cog;
514+
cv::Point cog;
515515
cog.x = closestBlob.get(0).asInt();
516516
cog.y = closestBlob.get(1).asInt();
517517

@@ -566,7 +566,7 @@ Bottle Manager::findBlobLoc()
566566
closestBlob=findClosestBlob(blobs,pointLocation);
567567
mutexResources.unlock();
568568

569-
CvPoint cog;
569+
cv::Point cog;
570570
cog.x = closestBlob.get(0).asInt();
571571
cog.y = closestBlob.get(1).asInt();
572572

@@ -601,7 +601,7 @@ bool Manager::executePCLGrasp( const string &objName )
601601
blobs.clear();
602602
bool invalid = false;
603603
bool isGrasped = false;
604-
CvPoint locObj;
604+
cv::Point locObj;
605605
Bottle result;
606606
result.clear();
607607

@@ -769,7 +769,7 @@ int Manager::executeToolSearchOnLoc( const string &objName )
769769
blobs=getBlobs();
770770
// failure handling
771771
Bottle result;
772-
CvPoint objLoc;
772+
cv::Point objLoc;
773773

774774
int objIndex = 0;
775775

@@ -1276,7 +1276,7 @@ int Manager::executeOnLoc(bool shouldTrain)
12761276
closestBlob=findClosestBlob(blobs,pointLocation);
12771277
mutexResources.unlock();
12781278

1279-
CvPoint cog;
1279+
cv::Point cog;
12801280
cog.x = closestBlob.get(0).asInt();
12811281
cog.y = closestBlob.get(1).asInt();
12821282

@@ -1370,7 +1370,7 @@ int Manager::executeOnLoc(bool shouldTrain)
13701370
rpcMotorKarma.write(karmaMotor, KarmaReply);
13711371
fprintf(stdout,"action is %s:\n",KarmaReply.toString().c_str());
13721372

1373-
CvPoint finalPoint;
1373+
cv::Point finalPoint;
13741374
if (particleFilter.getTraker(finalPoint))
13751375
{
13761376
while(finalPoint.x <1 && finalPoint.x >320 && finalPoint.y <1 && finalPoint.y >240)
@@ -1420,7 +1420,7 @@ double Manager::getBlobLenght(const Bottle &blobs, const int i)
14201420
double dist = 0;
14211421
if ((i>=0) && (i<blobs.size()))
14221422
{
1423-
CvPoint tl,br;
1423+
cv::Point tl,br;
14241424
Bottle *item=blobs.get(i).asList();
14251425
if (item==NULL)
14261426
return dist;
@@ -1464,7 +1464,7 @@ Bottle Manager::getOffset( Bottle &closestBlob, double actionOrient, Vector &ini
14641464

14651465
int axe1 = 0;
14661466
int axe2 = 0;
1467-
CvPoint cog;
1467+
cv::Point cog;
14681468
cog.x = closestBlob.get(0).asInt();
14691469
cog.y = closestBlob.get(1).asInt();
14701470

@@ -1482,7 +1482,7 @@ Bottle Manager::getOffset( Bottle &closestBlob, double actionOrient, Vector &ini
14821482
finalOrient -= orient;
14831483
}
14841484

1485-
CvPoint pxls;
1485+
cv::Point pxls;
14861486
Vector offPos;
14871487
fprintf(stdout,"The 3Dpos is %lf %lf %lf \n",initPos[0], initPos[1], initPos[2]);
14881488

@@ -1528,7 +1528,7 @@ Bottle Manager::classify(const Bottle &blobs, int index)
15281528
mutexResources.unlock();
15291529
//Bottle &toReturn = gotMils.addList();
15301530

1531-
CvPoint cog;
1531+
cv::Point cog;
15321532
cog=getBlobCOG(blobs,index);
15331533
Bottle &tmpLine = gotMils.addList();
15341534
Bottle &tmpMils = tmpLine.addList();
@@ -1587,7 +1587,7 @@ double Manager::getPeriod()
15871587
}
15881588

15891589
/**********************************************************/
1590-
bool Manager::get3DPosition(const CvPoint &point, Vector &x)
1590+
bool Manager::get3DPosition(const cv::Point &point, Vector &x)
15911591
{
15921592
Bottle cmdMotor,replyMotor;
15931593
cmdMotor.addVocab(Vocab::encode("get"));
@@ -1634,12 +1634,12 @@ Bottle Manager::getBlobs()
16341634
return lastBlobs;
16351635
}
16361636
/**********************************************************/
1637-
CvPoint Manager::getBlobCOG(const Bottle &blobs, const int i)
1637+
cv::Point Manager::getBlobCOG(const Bottle &blobs, const int i)
16381638
{
1639-
CvPoint cog=cvPoint(RET_INVALID,RET_INVALID);
1639+
cv::Point cog=cv::Point(RET_INVALID,RET_INVALID);
16401640
if ((i>=0) && (i<blobs.size()))
16411641
{
1642-
CvPoint tl,br;
1642+
cv::Point tl,br;
16431643
Bottle *item=blobs.get(i).asList();
16441644
if (item==NULL)
16451645
return cog;
@@ -1655,15 +1655,15 @@ CvPoint Manager::getBlobCOG(const Bottle &blobs, const int i)
16551655
return cog;
16561656
}
16571657
/**********************************************************/
1658-
Bottle Manager::findClosestBlob(const Bottle &blobs, const CvPoint &loc)
1658+
Bottle Manager::findClosestBlob(const Bottle &blobs, const cv::Point &loc)
16591659
{
16601660
int ret=RET_INVALID;
16611661
double min_d2=std::numeric_limits<double>::max();
16621662
Bottle pointReturn;
16631663
pointReturn.clear();
16641664
for (int i=0; i<blobs.size(); i++)
16651665
{
1666-
CvPoint cog=getBlobCOG(blobs,i);
1666+
cv::Point cog=getBlobCOG(blobs,i);
16671667
if ((cog.x==RET_INVALID) || (cog.y==RET_INVALID))
16681668
continue;
16691669

@@ -1677,7 +1677,7 @@ Bottle Manager::findClosestBlob(const Bottle &blobs, const CvPoint &loc)
16771677
ret=i;
16781678
}
16791679
}
1680-
CvPoint cog=getBlobCOG( blobs, ret );
1680+
cv::Point cog=getBlobCOG( blobs, ret );
16811681
pointReturn.addDouble(cog.x); //cog x
16821682
pointReturn.addDouble(cog.y); //cog y
16831683
pointReturn.addInt(ret); //index of blob

src/karmaManager/src/utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void ParticleFilter::onRead(Bottle &target)
4040
}
4141
}
4242
/**********************************************************/
43-
bool ParticleFilter::getTraker(CvPoint &loc)
43+
bool ParticleFilter::getTraker(cv::Point &loc)
4444
{
4545
loc=this->loc;
4646
return true;
@@ -76,7 +76,7 @@ PointedLocation::PointedLocation()
7676
timeout=2.0;
7777
}
7878
/**********************************************************/
79-
bool PointedLocation::getLoc(CvPoint &loc)
79+
bool PointedLocation::getLoc(cv::Point &loc)
8080
{
8181
double t0=Time::now();
8282

src/karmaToolProjection/include/iCub/utils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class MotionFeatures : public yarp::os::BufferedPort<yarp::os::Bottle>
4444
class ParticleFilter : public yarp::os::BufferedPort<yarp::os::Bottle>
4545
{
4646
protected:
47-
CvPoint loc;
47+
cv::Point loc;
4848
void onRead(yarp::os::Bottle &b);
4949
public:
5050
ParticleFilter();
51-
bool getTraker(CvPoint &loc);
51+
bool getTraker(cv::Point &loc);
5252
};
5353
/**********************************************************/
5454
class SegmentationPoint : public yarp::os::Port

src/karmaToolProjection/src/module.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void Manager::processBlobs(Bottle &b, cv::Mat &dest, lineData *lineDetails)
177177
ipt.y = (int) centers.at<float>(i,1);
178178

179179
pts[i] = ipt;
180-
circle( dest, ipt, 5, CV_RGB(255,255,255), CV_FILLED, CV_AA );
180+
circle( dest, ipt, 5, CV_RGB(255,255,255), cv::FILLED, cv::LINE_AA );
181181
}
182182
double gradient = 0;
183183
double intercept = 0;
@@ -190,7 +190,7 @@ void Manager::processBlobs(Bottle &b, cv::Mat &dest, lineData *lineDetails)
190190
Point endPoint;
191191
endPoint.x = (int)(pts[1].x + (double)(pts[1].x - pts[0].x) / lenAB * 50);
192192
endPoint.y = (int)(pts[1].y + (double) (pts[1].y - pts[0].y) / lenAB * 50);
193-
line(dest, pts[0], endPoint, Scalar(0,0,0), 2, CV_AA);
193+
line(dest, pts[0], endPoint, Scalar(0,0,0), 2, cv::LINE_AA);
194194
gradient = (double)( endPoint.y - pts[0].y ) / (double)( endPoint.x - pts[0].x );
195195
intercept = (double)( pts[0].y - (double)(pts[0].x * gradient) );
196196
lineDetails[1].gradient = gradient;
@@ -204,7 +204,7 @@ void Manager::processBlobs(Bottle &b, cv::Mat &dest, lineData *lineDetails)
204204
Point endPoint;
205205
endPoint.x = (int)(pts[0].x + (double)(pts[0].x - pts[1].x) / lenAB * 50);
206206
endPoint.y = (int)(pts[0].y + (double)(pts[0].y - pts[1].y) / lenAB * 50);
207-
line(dest, pts[1], endPoint, Scalar(0,0,0), 2, CV_AA);
207+
line(dest, pts[1], endPoint, Scalar(0,0,0), 2, cv::LINE_AA);
208208

209209
gradient = (double)( endPoint.y - pts[1].y) / (double)(endPoint.x - pts[1].x);
210210
intercept = (double)( endPoint.y - (double)(endPoint.x * gradient) );
@@ -312,7 +312,7 @@ Bottle Manager::processImage(Bottle &b, cv::Mat &dest, cv::Mat &clean, lineData
312312
fprintf(stdout,"0 < 3 %lf smaller than %lf \n", vtx[1].y, vtx[3].y);
313313
}
314314

315-
line(clean, vtx[j], vtx[(j+1)%4], Scalar(0,0,0), 2, CV_AA);
315+
line(clean, vtx[j], vtx[(j+1)%4], Scalar(0,0,0), 2, cv::LINE_AA);
316316
gradient = ( vtx[(j+1)%4].y - vtx[j].y) / (vtx[(j+1)%4].x - vtx[j].x);
317317
intercept = ( vtx[j].y - (vtx[j].x *gradient) );
318318

0 commit comments

Comments
 (0)