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
Customizable WebcamMotionDetector, WebcamUpdater, FsWebcamDevice #307
Comments
Hi @krok32, These are indeed very useful changes 👍 Please go ahead and do what you want to do. When you will be doing your changes please push them in separate pull requests (for motion detector, webcam updater and fswebcam driver). Just my few cents, so we keep the code style consistent:
class FsWebcamDevice {
final Map<String, ?> parameters;
FsWebcamDevice(File vfile, Map<String, ?> parameters) {
this.parameters = parameters;
}
...
} class FsWebcamDriver {
Map<String, ?> parameters = ...
public FsWebcamDriver(Map<String, ?> parameters) {
this.parameters = parameters;
}
@Override
public List<WebcamDevice> getDevices() {
for (File vfile : VFFILTER.getVideoFiles()) {
devices.add(new FsWebcamDevice(vfile, parameters));
}
}
...
} The source code indents are made by tabs. If you want you can reuse |
Customizable WebcamUpdater; issue #307
Regarding the device parameters, i suggest these changes
|
Hi @krok32, Adding new interface Except the public void setParameters(Map<String, ?> parameters) {
WebcamDevice device = getDevice();
if (device instanceof Configurable) {
((Configurable) device).setParameters(parameters);
} else {
LOG.debug("Webcam device {} is not configurable", device);
}
} And, of course, your new public boolean open(boolean async, DelayCalculator delayCalculator,Map<String, ?> parameters) {
if (open.compareAndSet(false, true)) {
setParameters(parameters);
...
}
...
} Please let me know if this fit into your idea and needs. I hope you don't mind if I add |
Ok,
|
Passing parameters to WebcamDevice instances, issue #307
Parametrized FsWebcamDriver and FsWebcamDevice issue #307
I'd like to implement further changes.
All of them should be backward compatible and allow customization.
1] WebcamMotionDetector
Currently, I can only override whole class WebcamMotionDetector, but fields are private, so it would be pain. Also WebcamMotionDetector implemens Runner and Inverter which i don't want to re-implement.
I suggest:
Algorithm for motion detection would be customizable, so part of the detect() method would be moved to the DefaultDetectorAlgorithm implementing IDetectorAlgorithm
I'm considering following methods:
BufferedImage IDetectorAlgorithm.prepareImage(BufferedImage original) // blur, gray, resize, etc...
boolean IDetectorAlgorithm.detect(BufferedImage previousModified, BufferedImage currentModified);
Poing IDetectorAlgorithm.getCog();
double IDetectorAlgorithm.getArea();
2] WebcamUpdater
Currently, I can't modify delay, and since I'm running it on RasPI, it's pretty slow and delay is always 0.
I suggest:
Part of the method WebcamUpdater.tick() would be moved to new class DefaultDelayCalculator implementing IDelayCalculator, so another implementation may be specified as parameter of Webcam.open() method.
Following method should be enough...
long IDelayCalculator.calculateDelay(snapshotDuration, deviceFps)
3] FsWebcamDevice
fswebcam needs some specific parameters to work reliably on RasPI with some cheap webcams.
If also some other drivers needed parameters, some common method
setParameters(Map<String,Object>) would be helpful.
I'm not sure about this. Anyway, I would commit configurable FsWebcamDevice if I knew how to parametrize it properly.
Please let me know what you thing about it, so I can implement it.
The text was updated successfully, but these errors were encountered: