error: invalid lvalue in assignment
Hello,
I'm getting this error:
../templates.hpp: In function 'Img crop(const Img&, const
cvmlcpp::iPoint2D&, const cvmlcpp::iPoint2D&) [with Img =
ili::BWImg]':
RectangleImageComparator.cc:85: instantiated from here
../templates.hpp:61: error: invalid lvalue in assignment
What's weird is that exactly the same template works with another
image type, as in the file where I instantiate it I have:
-------- begin extract RectangleImageComparator.cc -------
84 IntImg rectImg = crop<IntImg>(tempImage, corners[0],
corners[2]); // this function instantiates correctly
85 BWImg rectBWI = crop<BWImg>(bwImage, corners[0],
corners[2]); // if I eliminate this line (and all that uses the
result) all the code works
-------- end extract RectangleImageComparator.cc -------
The images are template classes defined like this:
typedef cvmlcpp::Matrix<bool , 2u> BWImg;
typedef cvmlcpp::Matrix<int_t, 2u> IntImg;
So, why would the instantiation work with the int version and not with
the boolean?? What does it mean the "error: invalid lvalue in
assignment", why does it appear only in the instantiation on the
boolean img??
Thanks for your help,
eD
-------- begin extract templates.hpp -------
29 template <class Img>
30 Img crop(const Img &img, const cvmlcpp::iPoint2D &ulc,
31 const cvmlcpp::iPoint2D &brc)
32 {
33 typedef typename Img::value_type T;
34
35
36 // check for valid arguments
37 // the image itself will take care of the out of bound
exception
38
39 /// \todo TODO put this function in the library
40 unsigned newHeight = ((brc[0] - ulc[0]) > 0) ? (brc[0] - ulc
[0]) : 0;
41 unsigned newWidth = ((brc[1] - ulc[1]) > 0) ? (brc[0] - ulc
[0]) : 0;
42
43 if (newHeight == 0)
44 {
45 std::invalid_argument myException("Height");
46 throw myException;
47 }
48 else if (newWidth == 0)
49 {
50 std::invalid_argument myException("Width");
51 throw myException;
52 }
53
54 Img myImage = ili::init<Img>(newHeight, newWidth);
55
56 // now we do the copying
57 for (unsigned i = 0; i < newHeight; i++)
58 {
59 for (unsigned j = 0; j < newWidth; j++)
60 {
61 myImage[i][j] = img[ulc[0] + i][ulc[1] + j]; // this
would be the line
62 }
63 }
64
65 return myImage;
66 }