如何从ac语言程序中调用LSD(LineSegmentDetector)?
我正在使用 LSD 来检测图像中的直线,我下载的代码包含调用 LSD 的最小示例,但它是静态的(即它仅输出主函数中的值)我想将代码应用于视频,这是输出静态结果的最小示例。
#include <stdio.h>
#include "lsd.h"
int main(void)
{
image_double image;
ntuple_list out;
unsigned int x,y,i,j;
unsigned int X = 512; /* x image size */
unsigned int Y = 512; /* y image size */
/* create a simple image: left half black, right half gray */
image = new_image_double(X,Y);
for(x=0;x<X;x++)
for(y=0;y<Y;y++)
image->data[ x + y * image->xsize ] = x<X/2 ? 0.0 : 64.0; /* image(x,y) */
IplImage* imgInTmp = cvLoadImage("C:\Documents and Settings\Eslam farag\My Documents\Visual Studio 2008\Projects\line\hand.JPEG", 0);
/* call LSD */
out = lsd(image);
/* print output */
printf("%u line segments found:\n",out->size);
for(i=0;i<out->size;i++)
{
for(j=0;j<out->dim;j++)
printf("%f ",out->values[ i * out->dim + j ]);
printf("\n");
}
/* free memory */
free_image_double(image);
free_ntuple_list(out);
return 0;
}
如果有人可以帮助我在视频上应用代码,我会很高兴。谢谢 此致,
i'm using LSD to detect straight lines in an image, the code that i have downloaded contains a Minimal example of calling LSD but it's static (i.e it outputs only the value in the main function) i want to apply the code on a video, that's the minimal example that outputs static results.
#include <stdio.h>
#include "lsd.h"
int main(void)
{
image_double image;
ntuple_list out;
unsigned int x,y,i,j;
unsigned int X = 512; /* x image size */
unsigned int Y = 512; /* y image size */
/* create a simple image: left half black, right half gray */
image = new_image_double(X,Y);
for(x=0;x<X;x++)
for(y=0;y<Y;y++)
image->data[ x + y * image->xsize ] = x<X/2 ? 0.0 : 64.0; /* image(x,y) */
IplImage* imgInTmp = cvLoadImage("C:\Documents and Settings\Eslam farag\My Documents\Visual Studio 2008\Projects\line\hand.JPEG", 0);
/* call LSD */
out = lsd(image);
/* print output */
printf("%u line segments found:\n",out->size);
for(i=0;i<out->size;i++)
{
for(j=0;j<out->dim;j++)
printf("%f ",out->values[ i * out->dim + j ]);
printf("\n");
}
/* free memory */
free_image_double(image);
free_ntuple_list(out);
return 0;
}
if anyone can help me to apply the code on video i will be pleased.thanks
best regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于我找不到完整的示例,因此我分享了我编写的代码,该代码使用 OpenCV 从磁盘加载视频文件并对其执行一些图像处理。
该应用程序将文件名作为输入(在命令行上),并使用 OpenCV 内置函数
cvCvtColor()
将视频的每一帧转换为其等效的灰度图像。我在代码中添加了一些注释,以帮助您理解基本任务。
read_video.cpp:
编译为:
如果您想知道如何迭代帧的像素来进行自定义处理,您需要检查以下答案,因为它展示了如何进行手动灰度转换。就这样:OpenCV cvSet2d.....这是做什么的< /a>
Since I couldn't find a complete example, I'm sharing a code I wrote that uses OpenCV to load a video file from the disk and perform some image processing on it.
The application takes a filename as input (on the cmd line) and converts each frame of the video to it's grayscale equivalent using OpenCV built-in function
cvCvtColor()
to do this.I added some comments on the code to help you understand the basic tasks.
read_video.cpp:
Compiled with:
If you want to know how to iterate through the pixels of the frame to do your custom processing, you need to check the following answer because it shows how to do a manual grayscale conversion. There you go: OpenCV cvSet2d.....what does this do
的代码示例
这是使用 LSD 与 opencv或这种方式
here is example of the code using LSD with opencv
or this way