{"action":"created","issue":{"url":"https://api.github.com/repos/sarxos/webcam-capture/issues/307","labels_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/307/comments","events_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/307/events","html_url":"https://github.com/sarxos/webcam-capture/issues/307","id":57182545,"number":307,"title":"Customizable WebcamMotionDetector, WebcamUpdater, FsWebcamDevice","user":{"login":"krok32","id":10794745,"avatar_url":"https://avatars.githubusercontent.com/u/10794745?v=3","gravatar_id":"","url":"https://api.github.com/users/krok32","html_url":"https://github.com/krok32","followers_url":"https://api.github.com/users/krok32/followers","following_url":"https://api.github.com/users/krok32/following{/other_user}","gists_url":"https://api.github.com/users/krok32/gists{/gist_id}","starred_url":"https://api.github.com/users/krok32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krok32/subscriptions","organizations_url":"https://api.github.com/users/krok32/orgs","repos_url":"https://api.github.com/users/krok32/repos","events_url":"https://api.github.com/users/krok32/events{/privacy}","received_events_url":"https://api.github.com/users/krok32/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sarxos/webcam-capture/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-10T14:38:59Z","updated_at":"2015-02-15T13:57:29Z","closed_at":null,"body":"I'd like to implement further changes. \r\nAll of them should be backward compatible and allow customization.\r\n\r\n1] WebcamMotionDetector\r\nCurrently, 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.\r\n\r\nI suggest:\r\nAlgorithm for motion detection would be customizable, so part of the detect() method would be moved to the DefaultDetectorAlgorithm implementing IDetectorAlgorithm\r\n\r\nI'm considering following methods:\r\nBufferedImage IDetectorAlgorithm.prepareImage(BufferedImage original) // blur, gray, resize, etc...\r\nboolean IDetectorAlgorithm.detect(BufferedImage previousModified, BufferedImage currentModified);\r\nPoing IDetectorAlgorithm.getCog();\r\ndouble IDetectorAlgorithm.getArea();\r\n\r\n2] WebcamUpdater\r\nCurrently, I can't modify delay, and since I'm running it on RasPI, it's pretty slow and delay is always 0.\r\n\r\nI suggest:\r\nPart 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.\r\n\r\nFollowing method should be enough...\r\nlong IDelayCalculator.calculateDelay(snapshotDuration, deviceFps)\r\n\r\n3] FsWebcamDevice\r\n\r\nfswebcam needs some specific parameters to work reliably on RasPI with some cheap webcams.\r\nIf also some other drivers needed parameters, some common method\r\nsetParameters(Map<String,Object>) would be helpful.\r\nI'm not sure about this. Anyway, I would commit configurable FsWebcamDevice if I knew how to parametrize it properly.\r\n\r\nPlease let me know what you thing about it, so I can implement it."},"comment":{"url":"https://api.github.com/repos/sarxos/webcam-capture/issues/comments/74418315","html_url":"https://github.com/sarxos/webcam-capture/issues/307#issuecomment-74418315","issue_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/307","id":74418315,"user":{"login":"sarxos","id":472658,"avatar_url":"https://avatars.githubusercontent.com/u/472658?v=3","gravatar_id":"","url":"https://api.github.com/users/sarxos","html_url":"https://github.com/sarxos","followers_url":"https://api.github.com/users/sarxos/followers","following_url":"https://api.github.com/users/sarxos/following{/other_user}","gists_url":"https://api.github.com/users/sarxos/gists{/gist_id}","starred_url":"https://api.github.com/users/sarxos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarxos/subscriptions","organizations_url":"https://api.github.com/users/sarxos/orgs","repos_url":"https://api.github.com/users/sarxos/repos","events_url":"https://api.github.com/users/sarxos/events{/privacy}","received_events_url":"https://api.github.com/users/sarxos/received_events","type":"User","site_admin":false},"created_at":"2015-02-15T13:57:29Z","updated_at":"2015-02-15T13:57:29Z","body":"Hi @krok32, \r\n\r\nAdding new interface ```ConfigurableDevice``` or simply ```Configurable``` is imho a better option than modifying ```WebcamDevice``` interface. This new interface could be public static inner interface of ```WebcamDevice```, same as ```BufferAccess``` and ```FPSSource``` are.\r\n\r\nExcept the ```Webcam.open(boolean async, DelayCalculator delayCalculator, Map<String, ?> params)``` please consider adding ```Webcam.setParameters(Map<String, ?> params)```, so one could set parameters before the ```open(..)``` is invoked.\r\n\r\n```java\r\npublic void setParameters(Map<String, ?> parameters) {\r\n  WebcamDevice device = getDevice();\r\n  if (device instanceof Configurable) {\r\n    ((Configurable) device).setParameters(parameters);\r\n  } else {\r\n    LOG.debug(\"Webcam device {} is not configurable\", device);\r\n  }\r\n}\r\n```\r\n\r\nAnd, of course, your new ```open(..)``` signature would be still added where ```setParameters(..)``` is invoked:\r\n\r\n```java\r\npublic boolean open(boolean async, DelayCalculator delayCalculator,Map<String, ?> parameters) {\r\n  if (open.compareAndSet(false, true)) {\r\n    setParameters(parameters);\r\n    ...\r\n  }\r\n  ...\r\n}\r\n```\r\n\r\nPlease let me know if this fit into your idea and needs.\r\n\r\nI hope you don't mind if I add ```@author Martin Krok (krok32)``` annotation on the classes/interfaces you created?"}}