# I was using opencv 2.3 o my project two years ago with the cvSet2D, but i use the command with opencv 3.4 i receive the message undeclared identifier

**URL:** <https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420>\
**Category:** C++\
**Tags:** core, historical\
**Created:** [September 30, 2021, 8:57am UTC](https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420 "2021-09-30T08:57:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alkassoum](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@alkassoum](https://forum.opencv.org/u/alkassoum)\
**Post date:** [September 30, 2021, 8:57am UTC](https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420/1 "2021-09-30T08:57:32Z")

</div>

i was using opencv 2.3 o my project two years ago with the cvSet2D, but i use the command with opencv 3.4 i receive the message undeclared identifier

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [September 30, 2021, 9:08am UTC](https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420/2 "2021-09-30T09:08:49Z")

</div>

the c-api is dead (since 10+ years !), no more maintained,  
and removed from the current codebase.  
you must NOT use it.

tell us, what your project is doing,  
then we can help you rewriting it (from scratch) in c++,  
point you at more modern samples, docs, etc.

---

<div class="post-metadata">

**Author:** ![alkassoum](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@alkassoum](https://forum.opencv.org/u/alkassoum)\
**Post date:** [October 4, 2021, 11:21am UTC](https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420/3 "2021-10-04T11:21:10Z")

</div>

thanks, i was working in treatment of image in advanced desert  
that’s the part of code

```auto

Mat mat2image(int **matrice)
{
	Mat image;
	Scalar pixel_val;
	int x, y;
	image.create(Size(Activerows, Activecols),3);// IPL_DEPTH_8U
																		   //for (x = 0; x<image->width; x++)
																		   //for (y = 0; y<image->height; y++)
	for (x = 0; x<Activerows; x++)
		for (y = 0; y<Activecols; y++)
		{
		//	pixel_val = image.at.cvGet2D(image,x, y);//toutes les composantes YCrCb
			pixel_val = image.at<int>(x,y);//toutes les composantes YCrCb
			pixel_val.val[0] = matrice[x][y];//Y
			image.at.cvSet2D(image,x, y, pixel_val);
		}

	return (image);
}

```

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [October 4, 2021, 1:54pm UTC](https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420/4 "2021-10-04T13:54:47Z")

</div>

some questions first:

so, you want to composite a YCrCb, and have the Y in matrice.

- where do the other channels come from ?
- youre confusing x \<-\> y, rows \<-\> cols here, that’s terrible … , but what about `matrice` again ?  
is it “row-mayor” ([y][x]) ?  
does it have continuous memory or “double pointers” ?

---

<div class="post-metadata">

**Author:** ![alkassoum](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@alkassoum](https://forum.opencv.org/u/alkassoum)\
**Post date:** [October 6, 2021, 8:35am UTC](https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420/5 "2021-10-06T08:35:18Z")

</div>

Thanks,  
I have a matric that i need to set a pixel to x and y positions where x represent a row position and y represent colon position  
last time i was using cvSet2D with opencv2 but when i use it now i receive the message:  
Erreur C2228 la partie gauche de ‘.cvSet2D’ doit avoir un class/struct/union

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [October 6, 2021, 9:29am UTC](https://forum.opencv.org/t/i-was-using-opencv-2-3-o-my-project-two-years-ago-with-the-cvset2d-but-i-use-the-command-with-opencv-3-4-i-receive-the-message-undeclared-identifier/5420/6 "2021-10-06T09:29:26Z")

</div>

assuming, `Activerows, Activecols` actually mean, what they say,  
try to stick with conventional `x:cols, y:rows` indexing

```auto
	Mat image(Activerows, Activecols, CV_8UC3); // Mat is 'row major'

	for (int x = 0; x<Activecols; x++)
		for (y = 0; y<Activerows; y++)
		{
            // get a *reference* to the pixel,
            // make sure to get the type right, CV_8UC3 <--> Vec3b
			Vec3b &pixel_val = image.at<Vec3b>(y,x);//toutes les composantes YCrCb
			pixel_val[0] = matrice[y][x];//Y
			pixel_val[1] = ????;//Cr
			pixel_val[2] = ????;//Cb
            // no need to 'set' anything, it's a reference
		}

```

for further reference, please [read tutorials](https://docs.opencv.org/master/de/d7a/tutorial_table_of_content_core.html)
