Why Value of SADWindowSize_slider become 0 when it assign to sbm->state,SADWindowSize

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why Value of SADWindowSize_slider become 0 when it assign to sbm->state,SADWindowSize

opencv-users mailing list


 

 Hi Everyone,
 

 i am testing stereoBM tunning parameters by GUI using opencv.
 

 Below is my code.
 

 Mat out1, out2;
 

 Size imageSize = out1.size();
 

 StereoBM sbm;
 

 /// Initialize values
 int preFilterType_slider = 0, preFilterCap_slider = 0, preFilterSize_slider = 0,
 

 minDisparity_slider = 0, uniqnessRatio_slider = 0, textureThreshold_slider = 0,
 

 speckleRange_slider = 0, sADWindowSize_slider = 5, spackleWindowSize_slider = 0,
 

 numDisparities_slider = 0, numDisparities2_slider = 0;
 

 

 

 int preFilterType_max = 1, preFilterCap_max = 61, preFilterSize_max = 100,
 

 minDisparity_max = 200, uniqnessRatio_max = 2500, textureThreshold_max = 10000,
 

 speckleRange_max = 500, sADWindowSize_max = 255, spackleWindowSize_max = 200,
 

 numDisparities_max = 500, numDisparities2_max = 0;
 

 

 Mat dispt, disp8, g1, g2;
 

 void on_trackbar_bmTunning(int , void*)
 {
 
 if (preFilterSize_slider % 2 == 0) preFilterSize_slider++;  //odd
 if (preFilterSize_slider < 5) preFilterSize_slider = 5;     //started from 5
 if (preFilterSize_slider > 255) preFilterSize_slider = 255; // to 255
 
 if (preFilterCap_slider < 1) preFilterCap_slider = 1;
 if (preFilterCap_slider > 63) preFilterCap_slider = 63;
 
 if (sADWindowSize_slider % 2 == 0) sADWindowSize_slider++;
 if (sADWindowSize_slider <= 5) sADWindowSize_slider = 5;
 if (sADWindowSize_slider > 255)sADWindowSize_slider = 255;
 if (sADWindowSize_slider >= MIN(imageSize.width, imageSize.height))
 sADWindowSize_slider = MIN(imageSize.width, imageSize.height);
 

 if (minDisparity_slider < 0) minDisparity_slider = 0;
 

 if (numDisparities_slider <1) numDisparities_slider = 1;
 
 if (textureThreshold_slider < 0) textureThreshold_slider = 1;
 
 if (uniqnessRatio_slider < 0) uniqnessRatio_slider = 1;
 

 

 //disp8 = g1.clone();
 

 sbm.state->speckleWindowSize = spackleWindowSize_slider;
 sbm.state->speckleRange = speckleRange_slider;
 sbm.state->preFilterSize = preFilterSize_slider; // 41
 sbm.state->preFilterCap = preFilterCap_slider; //31
 sbm.state->SADWindowSize = sADWindowSize_slider; //41
 sbm.state->minDisparity = minDisparity_slider *-16;//-64
 sbm.state->numberOfDisparities = numDisparities_slider * 16; //128
 sbm.state->textureThreshold = textureThreshold_slider; //10
 sbm.state->uniquenessRatio = uniqnessRatio_slider; //15
 

 sbm(g1, g2, dispt);
 

 normalize(dispt, disp8, 0, 255, CV_MINMAX, CV_8U);
 

 imshow("Tune BM Window ", disp8);
 }
 

 int test2_bmTunning() {
 

 out1 = imread("aloeL.jpg");
 
 out2 = imread("aloeR.jpg");
 
 cvtColor(out1, g1, CV_BGR2GRAY);
 
 cvtColor(out2, g2, CV_BGR2GRAY);
 

 namedWindow("Tune BM Window", CV_WINDOW_NORMAL);
 

 createTrackbar("Number of Disparities", "Tune BM Window", &preFilterType_slider, preFilterType_max, 0);
 
 createTrackbar("Pre Filter Cap", "Tune BM Window", &preFilterCap_slider, preFilterCap_max, on_trackbar_bmTunning);
 
 createTrackbar("Pre Filter Size", "Tune BM Window", &preFilterSize_slider, preFilterSize_max, on_trackbar_bmTunning);
 
 createTrackbar("Minimum Disparity", "Tune BM Window", &minDisparity_slider, minDisparity_max, on_trackbar_bmTunning);
 
 createTrackbar("Uniqueness Ratio", "Tune BM Window", &uniqnessRatio_slider, uniqnessRatio_max, on_trackbar_bmTunning);
 
 createTrackbar("Texture Threshold", "Tune BM Window", &textureThreshold_slider, textureThreshold_max, on_trackbar_bmTunning);
 

 createTrackbar("Speckle Range", "Tune BM Window", &speckleRange_slider, speckleRange_max, on_trackbar_bmTunning);
 

 createTrackbar("Block Size", "Tune BM Window", &sADWindowSize_slider, sADWindowSize_max, on_trackbar_bmTunning);
 
 createTrackbar("Speckle Window Size", "Tune BM Window", &spackleWindowSize_slider, spackleWindowSize_max, on_trackbar_bmTunning);
 
 createTrackbar("Number of Disparity", "Tune BM Window", &numDisparities_slider, numDisparities_max, on_trackbar_bmTunning);
 

 /// Show some stuff
 //on_trackbar_bmTunning(sADWindowSize_slider, 0);
 

 waitKey(0);
 

 return 0;
 }
 

 Problem :
 

 problem is when the value of  SADWindowSlize value from trackbar slider assign to sbm.state->SADWindowSize = sADWindowSize_slider; //41
 

 at this line of code, the value of sADWindowSize_slider become 0. and which gives me run  time error that SAD window size should be odd and in between 5 to 255.
 

 I am not getting that how value of SADWindowSize_slider become 0..
 

 Anyone pls guide me reason of this what is the problem.
 

 thanks
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why Value of SADWindowSize_slider become 0 when it assign to sbm->state,SADWindowSize

opencv-users mailing list
 eng.\ Awad A. Bekhet
BSc. of Computer Engineering
Al Azhar University, Computers and Systems Department, 2011
Embedded Systems Engineer




 about.me/awadbekhet
http://www.facebook.com/eng.AwadBekhet
+201008522621







    On Friday, May 26, 2017 9:37 AM, "[hidden email] [OpenCV]" <[hidden email]> wrote:



  


Hi Everyone, 
i am testing stereoBM tunning parameters by GUI using opencv. 
Below is my code. 

Mat out1, out2;
Size imageSize = out1.size();
StereoBM sbm;
/// Initialize valuesint preFilterType_slider = 0, preFilterCap_slider = 0, preFilterSize_slider = 0,
minDisparity_slider = 0, uniqnessRatio_slider = 0, textureThreshold_slider = 0,
speckleRange_slider = 0, sADWindowSize_slider = 5, spackleWindowSize_slider = 0,
numDisparities_slider = 0, numDisparities2_slider = 0;




int preFilterType_max = 1, preFilterCap_max = 61, preFilterSize_max = 100,
minDisparity_max = 200, uniqnessRatio_max = 2500, textureThreshold_max = 10000,
speckleRange_max = 500, sADWindowSize_max = 255, spackleWindowSize_max = 200,
numDisparities_max = 500, numDisparities2_max = 0;


Mat dispt, disp8, g1, g2;
void on_trackbar_bmTunning(int , void*){  if (preFilterSize_slider % 2 == 0) preFilterSize_slider++;  //odd if (preFilterSize_slider < 5) preFilterSize_slider = 5;     //started from 5 if (preFilterSize_slider > 255) preFilterSize_slider = 255; // to 255  if (preFilterCap_slider < 1) preFilterCap_slider = 1; if (preFilterCap_slider > 63) preFilterCap_slider = 63;  if (sADWindowSize_slider % 2 == 0) sADWindowSize_slider++; if (sADWindowSize_slider <= 5) sADWindowSize_slider = 5; if (sADWindowSize_slider > 255)sADWindowSize_slider = 255; if (sADWindowSize_slider >= MIN(imageSize.width, imageSize.height)) sADWindowSize_slider = MIN(imageSize.width, imageSize.height);
 if (minDisparity_slider < 0) minDisparity_slider = 0;
 if (numDisparities_slider <1) numDisparities_slider = 1;  if (textureThreshold_slider < 0) textureThreshold_slider = 1;  if (uniqnessRatio_slider < 0) uniqnessRatio_slider = 1;


 //disp8 = g1.clone();
 sbm.state->speckleWindowSize = spackleWindowSize_slider; sbm.state->speckleRange = speckleRange_slider; sbm.state->preFilterSize = preFilterSize_slider; // 41 sbm.state->preFilterCap = preFilterCap_slider; //31 sbm.state->SADWindowSize = sADWindowSize_slider; //41 sbm.state->minDisparity = minDisparity_slider *-16;//-64 sbm.state->numberOfDisparities = numDisparities_slider * 16; //128 sbm.state->textureThreshold = textureThreshold_slider; //10 sbm.state->uniquenessRatio = uniqnessRatio_slider; //15
 sbm(g1, g2, dispt);
 normalize(dispt, disp8, 0, 255, CV_MINMAX, CV_8U);
 imshow("Tune BM Window ", disp8);}
int test2_bmTunning() {
 out1 = imread("aloeL.jpg");  out2 = imread("aloeR.jpg");  cvtColor(out1, g1, CV_BGR2GRAY);  cvtColor(out2, g2, CV_BGR2GRAY);
 namedWindow("Tune BM Window", CV_WINDOW_NORMAL);
 createTrackbar("Number of Disparities", "Tune BM Window", &preFilterType_slider, preFilterType_max, 0);  createTrackbar("Pre Filter Cap", "Tune BM Window", &preFilterCap_slider, preFilterCap_max, on_trackbar_bmTunning);  createTrackbar("Pre Filter Size", "Tune BM Window", &preFilterSize_slider, preFilterSize_max, on_trackbar_bmTunning);  createTrackbar("Minimum Disparity", "Tune BM Window", &minDisparity_slider, minDisparity_max, on_trackbar_bmTunning);  createTrackbar("Uniqueness Ratio", "Tune BM Window", &uniqnessRatio_slider, uniqnessRatio_max, on_trackbar_bmTunning);  createTrackbar("Texture Threshold", "Tune BM Window", &textureThreshold_slider, textureThreshold_max, on_trackbar_bmTunning);
 createTrackbar("Speckle Range", "Tune BM Window", &speckleRange_slider, speckleRange_max, on_trackbar_bmTunning);
 createTrackbar("Block Size", "Tune BM Window", &sADWindowSize_slider, sADWindowSize_max, on_trackbar_bmTunning);  createTrackbar("Speckle Window Size", "Tune BM Window", &spackleWindowSize_slider, spackleWindowSize_max, on_trackbar_bmTunning);  createTrackbar("Number of Disparity", "Tune BM Window", &numDisparities_slider, numDisparities_max, on_trackbar_bmTunning);
 /// Show some stuff //on_trackbar_bmTunning(sADWindowSize_slider, 0);
 waitKey(0);
 return 0;}
Problem : 
problem is when the value of  SADWindowSlize value from trackbar slider assign to sbm.state->SADWindowSize = sADWindowSize_slider; //41
at this line of code, the value of sADWindowSize_slider become 0. and which gives me run  time error that SAD window size should be odd and in between 5 to 255. 
I am not getting that how value of SADWindowSize_slider become 0..
Anyone pls guide me reason of this what is the problem. 
thanks    #yiv6068679343 #yiv6068679343 -- #yiv6068679343ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv6068679343 #yiv6068679343ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv6068679343 #yiv6068679343ygrp-mkp #yiv6068679343hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv6068679343 #yiv6068679343ygrp-mkp #yiv6068679343ads {margin-bottom:10px;}#yiv6068679343 #yiv6068679343ygrp-mkp .yiv6068679343ad {padding:0 0;}#yiv6068679343 #yiv6068679343ygrp-mkp .yiv6068679343ad p {margin:0;}#yiv6068679343 #yiv6068679343ygrp-mkp .yiv6068679343ad a {color:#0000ff;text-decoration:none;}#yiv6068679343 #yiv6068679343ygrp-sponsor #yiv6068679343ygrp-lc {font-family:Arial;}#yiv6068679343 #yiv6068679343ygrp-sponsor #yiv6068679343ygrp-lc #yiv6068679343hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv6068679343 #yiv6068679343ygrp-sponsor #yiv6068679343ygrp-lc .yiv6068679343ad {margin-bottom:10px;padding:0 0;}#yiv6068679343 #yiv6068679343actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv6068679343 #yiv6068679343activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv6068679343 #yiv6068679343activity span {font-weight:700;}#yiv6068679343 #yiv6068679343activity span:first-child {text-transform:uppercase;}#yiv6068679343 #yiv6068679343activity span a {color:#5085b6;text-decoration:none;}#yiv6068679343 #yiv6068679343activity span span {color:#ff7900;}#yiv6068679343 #yiv6068679343activity span .yiv6068679343underline {text-decoration:underline;}#yiv6068679343 .yiv6068679343attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv6068679343 .yiv6068679343attach div a {text-decoration:none;}#yiv6068679343 .yiv6068679343attach img {border:none;padding-right:5px;}#yiv6068679343 .yiv6068679343attach label {display:block;margin-bottom:5px;}#yiv6068679343 .yiv6068679343attach label a {text-decoration:none;}#yiv6068679343 blockquote {margin:0 0 0 4px;}#yiv6068679343 .yiv6068679343bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv6068679343 .yiv6068679343bold a {text-decoration:none;}#yiv6068679343 dd.yiv6068679343last p a {font-family:Verdana;font-weight:700;}#yiv6068679343 dd.yiv6068679343last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv6068679343 dd.yiv6068679343last p span.yiv6068679343yshortcuts {margin-right:0;}#yiv6068679343 div.yiv6068679343attach-table div div a {text-decoration:none;}#yiv6068679343 div.yiv6068679343attach-table {width:400px;}#yiv6068679343 div.yiv6068679343file-title a, #yiv6068679343 div.yiv6068679343file-title a:active, #yiv6068679343 div.yiv6068679343file-title a:hover, #yiv6068679343 div.yiv6068679343file-title a:visited {text-decoration:none;}#yiv6068679343 div.yiv6068679343photo-title a, #yiv6068679343 div.yiv6068679343photo-title a:active, #yiv6068679343 div.yiv6068679343photo-title a:hover, #yiv6068679343 div.yiv6068679343photo-title a:visited {text-decoration:none;}#yiv6068679343 div#yiv6068679343ygrp-mlmsg #yiv6068679343ygrp-msg p a span.yiv6068679343yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv6068679343 .yiv6068679343green {color:#628c2a;}#yiv6068679343 .yiv6068679343MsoNormal {margin:0 0 0 0;}#yiv6068679343 o {font-size:0;}#yiv6068679343 #yiv6068679343photos div {float:left;width:72px;}#yiv6068679343 #yiv6068679343photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv6068679343 #yiv6068679343photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv6068679343 #yiv6068679343reco-category {font-size:77%;}#yiv6068679343 #yiv6068679343reco-desc {font-size:77%;}#yiv6068679343 .yiv6068679343replbq {margin:4px;}#yiv6068679343 #yiv6068679343ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv6068679343 #yiv6068679343ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv6068679343 #yiv6068679343ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv6068679343 #yiv6068679343ygrp-mlmsg select, #yiv6068679343 input, #yiv6068679343 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv6068679343 #yiv6068679343ygrp-mlmsg pre, #yiv6068679343 code {font:115% monospace;}#yiv6068679343 #yiv6068679343ygrp-mlmsg * {line-height:1.22em;}#yiv6068679343 #yiv6068679343ygrp-mlmsg #yiv6068679343logo {padding-bottom:10px;}#yiv6068679343 #yiv6068679343ygrp-msg p a {font-family:Verdana;}#yiv6068679343 #yiv6068679343ygrp-msg p#yiv6068679343attach-count span {color:#1E66AE;font-weight:700;}#yiv6068679343 #yiv6068679343ygrp-reco #yiv6068679343reco-head {color:#ff7900;font-weight:700;}#yiv6068679343 #yiv6068679343ygrp-reco {margin-bottom:20px;padding:0px;}#yiv6068679343 #yiv6068679343ygrp-sponsor #yiv6068679343ov li a {font-size:130%;text-decoration:none;}#yiv6068679343 #yiv6068679343ygrp-sponsor #yiv6068679343ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv6068679343 #yiv6068679343ygrp-sponsor #yiv6068679343ov ul {margin:0;padding:0 0 0 8px;}#yiv6068679343 #yiv6068679343ygrp-text {font-family:Georgia;}#yiv6068679343 #yiv6068679343ygrp-text p {margin:0 0 1em 0;}#yiv6068679343 #yiv6068679343ygrp-text tt {font-size:120%;}#yiv6068679343 #yiv6068679343ygrp-vital ul li:last-child {border-right:none !important;}#yiv6068679343


Loading...