Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Multiple OpenTLD objects to Track Multiple objects #47

Open
vreddy1990 opened this issue Mar 2, 2014 · 2 comments
Open

Creating Multiple OpenTLD objects to Track Multiple objects #47

vreddy1990 opened this issue Mar 2, 2014 · 2 comments

Comments

@vreddy1990
Copy link

Instead of running multiple instances of OpenTLD application, would there be any problems in creating a class called OpenTLD and creating multiple instances of the class for tracking multiple objects? The OPenTLD class that I created has its own Main* etc.. and thus when used as an imported dll could easily track multiple objects.

Does any of the code have any static variables / objects that may be shared by all Main objects? This is the only problem that I am anticipating. If anyone has any advice please let me know. At present when I create the second OpenTLD object it works fine until I start running the TLD methods on the second object then the application crashes.

@vreddy1990
Copy link
Author

Can someone please advice me on how to handle
int success = fbtrack(&prevImg, &currImg, bb_tracker, bb_tracker, &scale);
If I skip this code I am able to run multiple instances of the OpenTLD class that I have created. This function is the culprit in crashing the program if a second instance is created. There is a static IplImage **PYR = 0; in Lk.cpp that may be a problem. I tried setting up a non-static IplImage pointer in Median Flow Tracker and passed its address through the intermediary functions to the fuctions that use PYR but it does not do the job. It actually crashes the program now with just one instance of OpenTLD.

@vreddy1990
Copy link
Author

Resolved the crash by locking the following function calls while a thread is accessing them in FBTrack.cpp, fbtrack(... ... ...)
#include
mutex mtex;

mtex.lock();
initImgs();
trackLK(imgI, imgJ, pt, nPoints, ptTracked, nPoints, level, fb, ncc, status);
initImgs();
mtex.unlock();

This way race condition is avoided. The two functions defined in Lk.cpp should ideally be in a class with non static members so that multiple threads are not stopped while waiting for unlock.

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

Successfully merging a pull request may close this issue.

1 participant