Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Edge Detect Sliders Not Responding #19

Open
ryanpeach opened this issue Dec 2, 2015 · 0 comments
Open

Edge Detect Sliders Not Responding #19

ryanpeach opened this issue Dec 2, 2015 · 0 comments

Comments

@ryanpeach
Copy link
Owner

main.cpp

struct udata {
    Capture *capt;
    Par param;
} token;

Capture C;
int etol1, etol2, eSize, polyTol;
int cBlock, cSize, k, cThresh;

void setTrackBar(int v, void* userdata){
    cout << "Running setTrackBar..." << endl;
    udata t = *((udata*)(userdata));
    cout << t.param << " " << v << endl;
    (t.capt)->setValue((t.param), v);
}

void createTrackbar(String vname, String wname, int* v, int maxv, Capture* c, Par param) {
    token = {c, param}; 
    createTrackbar(vname, wname, v, maxv, &setTrackBar, &token);
}

void videoProcess(VideoCapture cap, Capture* c) {
    ...
    ...
    createTrackbar("eTol1", "Canny Edge Detection", &etol1, 255, c, ETOL1);
    createTrackbar("eTol2", "Canny Edge Detection", &etol2, 255, c, ETOL2); 
    createTrackbar("eSize", "Canny Edge Detection", &eSize, 21, c, ESIZE);
    createTrackbar("polyTol", "Polys, Rects, & Fps", &polyTol, 200, c, POLYTOL);
    createTrackbar("cBlock", "Polys, Rects, & Fps", &cBlock, 21, c, CBLOCK);
    createTrackbar("cSize", "Polys, Rects, & Fps", &cSize, 21, c, CSIZE);
    createTrackbar("k", "Polys, Rects, & Fps", &k, 21, c, K);
    createTrackbar("cThresh", "Polys, Rects, & Fps", &cThresh, 255, c, CTHRESH);
}

capture.cpp

namespace OPT {
const double VSCALE = 1000.0;
enum Method {fpcorners, strongborder, regular, automatic};
enum PageType {detect, letter};
enum Par {ANGLETOL, DISTTOL, POLYTOL, ASPECTRATIO, SIZERATIO, RATIOTOL, ETOL1, ETOL2, ESIZE, METHOD,
            CBLOCK, CSIZE, K, CTHRESH};
}

using namespace OPT;

void Capture::setValue(Par param, int value) {
    auto toDouble = [](int v) {return ((double)v)/VSCALE;};
    switch(param) {
        case ANGLETOL: angleTol = value; break;
        case DISTTOL: distTol = value; break;
        case POLYTOL: polyTol = value; break;
        case ASPECTRATIO: setAspectRatio((PageType)value); break;
        case SIZERATIO: sizeRatio = toDouble(value); break;
        case RATIOTOL: ratioTol = toDouble(value); break;
        case ETOL1: etol1 = value; break;
        case ETOL2: etol2 = value; break;
        case ESIZE: eSize = value; break;
        case CBLOCK: cBlock = value; break;
        case CSIZE: cSize = value; break;
        case K: k = value; break;
        case CTHRESH: cThresh = value; break;
        case METHOD: sel = (Method)value; break;
        default: break;
    }
}

When this is run, all the other sliders update their selected values, but ETOL1, ETOL2, and ESIZE appear not to. This may be because the param does not select the proper case statement due to pointer issues in the struct.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant