Contours Detection for 3D objects

Dear Team,

I would like to ask if there is a code in c++ which loads an 3d obj and find the edges of that specific object.
I have only found the below code but is only for 2d files.
Thanks in advance.

include <opencv2/opencv.hpp>
// using namespaces to nullify use of cv::function(); syntax and std::function();
using namespace std;
using namespace cv;

int main()
// Reading image
Mat img = imread(“test.png”);
// Display original image
imshow(“original Image”, img);

// Convert to graycsale
Mat img_gray;
cvtColor(img, img_gray, COLOR_BGR2GRAY);
// Blur the image for better edge detection
Mat img_blur;
GaussianBlur(img_gray, img_blur, Size(3, 3), 0);

// Sobel edge detection
Mat sobelx, sobely, sobelxy;
Sobel(img_blur, sobelx, CV_64F, 1, 0, 5);
Sobel(img_blur, sobely, CV_64F, 0, 1, 5);
Sobel(img_blur, sobelxy, CV_64F, 1, 1, 5);
// Display Sobel edge detection images
imshow("Sobel X", sobelx);
imshow("Sobel Y", sobely);
imshow("Sobel XY using Sobel() function", sobelxy);
// Canny edge detection
Mat edges;
Canny(img_blur, edges, 100, 200, 3, false);
// Display canny edge detected image
imshow("Canny edge detection", edges);
imwrite("Golik_Canny_auto.jpg", edges);

return 0;


3d files usually contain vertices and triangles – so – what are you trying to achieve here ? why would you want a mainly 2d computer-vision library for this ?

thanks berak for your promt reply,

maybe i wrote it wrong, my purpose is to extract the contour from an 3d object. Is it possible via opencv ?

use PCL. it’s a different library.