91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6.12MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-11-01
  • 語言: 其他
  • 標(biāo)簽: opencv??

資源簡介

本程序基于OpenCv給出了一種車道線檢測的算法,首先通過OSTU進(jìn)行二值化處理,隨后通過改進(jìn)的霍夫變化進(jìn)行車道線檢測,具有比較好的效果。

資源截圖

代碼片段和文件信息

//---------------------車道線檢測-------------------------//

/*可以處理攝像頭,也可以處理視頻文件*/


#include?
#include?
#include?
#include?
#include?
#include?


using?namespace?cv;
using?namespace?std;

CvCapture*?g_capture?=?NULL;
IplImage*?PreProcessImg?=?NULL;
CvPoint?point1?point2?point3?pointend?pointtemp;
CvPoint?pointmeet;//相交點(diǎn)

vector?points;
vector?pointsleft;
vector?pointsright;

//結(jié)構(gòu)體1,左側(cè)的線,右側(cè)的線
struct?line
{
CvPoint?pointbottom;
CvPoint?pointtop;
}lineleft?lineright;

//結(jié)構(gòu)體2
struct?greycount
{
uchar?grey;
int?count;
};

//大津閾值車道從背景中分離出來
void?ImproveOTSU(IplImage*?image?IplImage*?image2)
{


//int?lc?=?cvRound((image->height?/?2)?+?1);
//cvSetImageROI(image?cvRect(0?lc?image->width?image->height));

//如果只對(duì)下半幅圖像做大津閾值,效果不好
//cvThreshold(image?image?80?255?CV_THRESH_BINARY);//速度慢,與OSTU差100ms
//cvThreshold(image?image2?180?235?CV_THRESH_BINARY_INV?|?CV_THRESH_OTSU);//BINARY能檢測出視頻3-2
cvThreshold(image?image2?0?255?CV_THRESH_OTSU);//改變閾值沒效果
//cvResetImageROI(image);
//cvCopy(image?image2);

}

//改進(jìn)的hough變換檢測車道
int?Hough(IplImage*?image?float*?tabSin?float?*tabCos?int?*accum?int?numrho?int?&predistance1?int?&preangle1?int?&predistance2?int?&preangle2)
{
int?r?angle1?=?1?angle2?=?1?distance1?=?0?distance2?=?0?n?=?0;
long?j;
int?angelstart1?=?40;
int?angleend1?=?70;
int?anglestart2?=?110;
int?angleend2?=?160;

if?(preangle1?!=?0)
{
angelstart1?=?preangle1?-?5;
angleend1?=?preangle1?+?5;
}
if?(preangle2?!=?0)
{
anglestart2?=?preangle2?-?5;
angleend2?=?preangle2?+?5;
}

int?step?=?image->widthStep?/?sizeof(uchar);
uchar?*data0?=?(uchar?*)image->imageData;

for?(int?i?=?image->height?/?2;?i?height;?i++)
{
for?(j?=?0;?j?width;?j++)
{
if?(data0[i*step?+?j]?==?255)//??
{
for?(n?=?angelstart1;?n? {
r?=?cvRound(j?*?tabCos[n]?+?i?*?tabSin[n]);
r?+=?(numrho?-?1)?/?2;
accum[(n?+?1)?*?(numrho?+?2)?+?r?+?1]++;
}
for?(n?=?anglestart2;?n? {

r?=?cvRound(j?*?tabCos[n]?+?i?*?tabSin[n]);
r?+=?(numrho?-?1)?/?2;
accum[(n?+?1)?*?(numrho?+?2)?+?r?+?1]++;
}
}
}
}
//printf(“preangle1preangle2:%d?%d\n?“preangle1preangle2);
//找出數(shù)值最大的小格
int?numbermax1?=?30?numbermax2?=?30;

for?(r?=?0;?r? {
for?(n?=?40;?n? {
int?base?=?(n?+?1)?*?(numrho?+?2)?+?r?+?1;
if?(accum[base]?>?numbermax1)
{
numbermax1?=?accum[base];
angle1?=?n;
distance1?=?cvRound(r?-?(numrho?-?1)*0.5f);
}
}
for?(n?=?110;?n<160;?n++)
{
int?base?=?(n?+?1)?*?(numrho?+?2)?+?r?+?1;
if?(accum[base]?>?numbermax2)
{
numbermax2?=?accum[base];
angle2?=?n;
distance2?=?cvRound(r?-?(numrho?-?1)*0.5f);
}
}
}

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件??????18490??2017-11-20?18:23??車道線.cpp

?????文件????6457025??2017-11-21?08:59??1.mp4

-----------?---------??----------?-----??----

??????????????6475515????????????????????2


評(píng)論

共有 條評(píng)論

相關(guān)資源