{"action":"created","comment":{"url":"https://api.github.com/repos/inilabs/caer/pulls/comments/65167257","id":65167257,"diff_hunk":"@@ -0,0 +1,208 @@\n+#include \"accumulatefilter.h\"\n+#include \"base/mainloop.h\"\n+#include \"base/module.h\"\n+\n+// define state/internal vars of the filter\n+struct AccFilter_state {\n+        // time packet\n+\tint64_t close; //close time for current packet\n+        caerPolarityEventPacket *curr;\n+        caerPolarityEventPacket *next; //backlog packet\n+\tint32_t deltaT;\n+        // 2D buffer\n+\tint16_t buff2dMaxX;\n+\tint16_t buff2dMaxY;\n+\tint64_t **buff2D;\n+        polarity_t mode;\n+        // 1D buffer        \n+        int32_t buff1dMax;\n+        int64_t *buff1D;\n+};\n+\n+typedef struct AccFilter_state *AccFilterState;\n+\n+// required methods\n+static bool caerAccumulateFilterInit(caerModuleData moduleData);\n+static void caerAccumulateFilterRun(caerModuleData moduleData, size_t argsNumber, va_list args);\n+static void caerAccumulateFilterConfig(caerModuleData moduleData);\n+static void caerAccumulateFilterExit(caerModuleData moduleData);\n+//helpers\n+static bool allocate2DBuffer(AccFilterState state, int16_t sizeX, int16_t sizeY);\n+static void transform1D(int64_t* vector1D, uint16_t x, uint16_t y, bool p);\n+static void processEvent(AccFilterState state, caerPolarityEvent evt, caerPolarityEventPacket packet);\n+\n+// map functions to filter handlers\n+static struct caer_module_functions caerAccumulateFilterFunctions = { \n+\t.moduleInit = &caerAccumulateFilterInit, \n+\t.moduleRun = &caerAccumulateFilterRun, \n+\t.moduleConfig = &caerAccumulateFilterConfig, \n+\t.moduleExit = &caerAccumulateFilterExit };\n+\n+// this is called from mainloop\n+void caerAccumulateFilter(uint16_t moduleID, caerPolarityEventPacket polarity) {\n+\tcaerModuleData moduleData = caerMainloopFindModule(moduleID, \"AccFilter\");\n+\tcaerModuleSM(&caerAccumulateFilterFunctions, moduleData, sizeof(struct AccFilter_state), 1, polarity);\n+}\n+\n+static bool caerAccumulateFilterInit(caerModuleData moduleData) {\n+\tsshsNodePutIntIfAbsent(moduleData->moduleNode, \"deltaT\", 1000);\n+        sshsNodePutIntIfAbsent(moduleData->moduleNode, \"buff1dMax\", 1000); //depends on transform() function\n+\n+\tsshsNodeAddAttributeListener(moduleData->moduleNode, moduleData, &caerModuleConfigDefaultListener);\n+\n+        caerAccumulateFilterConfig(moduleData);\n+\t// Nothing that can fail here.\n+\treturn (true);\n+}\n+\n+static void caerAccumulateFilterRun(caerModuleData moduleData, size_t argsNumber, va_list args) {\n+\tUNUSED_ARGUMENT(argsNumber);\n+\n+\t// Interpret variable arguments (same as above in main function).\n+\tcaerPolarityEventPacket polarity = va_arg(args, caerPolarityEventPacket);\n+\n+\t// Only process packets with content.\n+\tif (polarity == NULL) {\n+\t\treturn;\n+\t}\n+\n+\tAccFilterState state = moduleData->moduleState;\n+\n+        // update camera dimensions\n+        if(state->buff2dMaxX == -1 || state->buff2dMaxY == -1) { //FIXME this should be in Init() if I know \"dvsSizeX\" at the time\n+          // Get size information from source.\n+          uint16_t sourceID = caerEventPacketHeaderGetEventSource(&polarity->packetHeader);\n+          sshsNode sourceInfoNode = caerMainloopGetSourceInfo((uint16_t) sourceID);\n+          state->buff2dMaxX = sshsNodeGetShort(sourceInfoNode, \"dvsSizeX\");\n+          state->buff2dMaxY = sshsNodeGetShort(sourceInfoNode, \"dvsSizeY\");\n+          free(sourceInfoNode); sourceInfoNode = NULL;\n+          // allocate 2D buffer\n+          if (state->buff2D == NULL && (state->buff2dMaxX != -1 || state->buff2dMaxY != -1)) {\n+                if (!allocate2DBuffer(state, state->buff2dMaxX, state->buff2dMaxY)) {\n+                        // Failed to allocate memory, nothing to do.\n+                        caerLog(CAER_LOG_ERROR, moduleData->moduleSubSystemString, \"Failed to allocate memory for buff2D.\");\n+                        return;\n+                }\n+          }\n+        }\n+\n+        CAER_POLARITY_ITERATOR_VALID_START(state->next) //process all evts from previous next","path":"modules/accumulatefilter/accumulatefilter.c","position":null,"original_position":89,"commit_id":"8ef50f20a9d016d0196a7df41f8c54226667241f","original_commit_id":"29d160222fe1a1be27fbac9c3f5041c55adea720","user":{"login":"breznak","id":2166111,"avatar_url":"https://avatars.githubusercontent.com/u/2166111?v=3","gravatar_id":"","url":"https://api.github.com/users/breznak","html_url":"https://github.com/breznak","followers_url":"https://api.github.com/users/breznak/followers","following_url":"https://api.github.com/users/breznak/following{/other_user}","gists_url":"https://api.github.com/users/breznak/gists{/gist_id}","starred_url":"https://api.github.com/users/breznak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breznak/subscriptions","organizations_url":"https://api.github.com/users/breznak/orgs","repos_url":"https://api.github.com/users/breznak/repos","events_url":"https://api.github.com/users/breznak/events{/privacy}","received_events_url":"https://api.github.com/users/breznak/received_events","type":"User","site_admin":false},"body":"> Basically just have the two maps and one big 'accumulator' packet, and go through the current event packets one by one, adding to them.\r\n\r\nI think I need the 2nd packet for events that are further away then my window, no? E.g ` older (drop) < evt inside my window (append) < evt further than the window` ","created_at":"2016-05-31T11:51:32Z","updated_at":"2016-05-31T11:51:32Z","html_url":"https://github.com/inilabs/caer/pull/2#discussion_r65167257","pull_request_url":"https://api.github.com/repos/inilabs/caer/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/inilabs/caer/pulls/comments/65167257"},"html":{"href":"https://github.com/inilabs/caer/pull/2#discussion_r65167257"},"pull_request":{"href":"https://api.github.com/repos/inilabs/caer/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/inilabs/caer/pulls/2","id":69523473,"html_url":"https://github.com/inilabs/caer/pull/2","diff_url":"https://github.com/inilabs/caer/pull/2.diff","patch_url":"https://github.com/inilabs/caer/pull/2.patch","issue_url":"https://api.github.com/repos/inilabs/caer/issues/2","number":2,"state":"open","locked":false,"title":"[WIP] new Accumulate filter for cAER","user":{"login":"breznak","id":2166111,"avatar_url":"https://avatars.githubusercontent.com/u/2166111?v=3","gravatar_id":"","url":"https://api.github.com/users/breznak","html_url":"https://github.com/breznak","followers_url":"https://api.github.com/users/breznak/followers","following_url":"https://api.github.com/users/breznak/following{/other_user}","gists_url":"https://api.github.com/users/breznak/gists{/gist_id}","starred_url":"https://api.github.com/users/breznak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breznak/subscriptions","organizations_url":"https://api.github.com/users/breznak/orgs","repos_url":"https://api.github.com/users/breznak/repos","events_url":"https://api.github.com/users/breznak/events{/privacy}","received_events_url":"https://api.github.com/users/breznak/received_events","type":"User","site_admin":false},"body":"The filter allows aggregation of events by time, and an additional output to 2D and 1D arrays.\r\n\r\nDiscussion moved from https://sourceforge.net/p/jaer/discussion/631958/thread/1d5333fa/ \r\n\r\nTODO: \r\nThis PR can take advantage of the following issues when implemented:\r\n- [ ] #6\r\n- [ ] #8\r\n- [x] #7 ","created_at":"2016-05-10T15:11:01Z","updated_at":"2016-05-31T11:51:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b1d54caef31e211609ef36565edd26798d7fff1b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/inilabs/caer/pulls/2/commits","review_comments_url":"https://api.github.com/repos/inilabs/caer/pulls/2/comments","review_comment_url":"https://api.github.com/repos/inilabs/caer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inilabs/caer/issues/2/comments","statuses_url":"https://api.github.com/repos/inilabs/caer/statuses/8ef50f20a9d016d0196a7df41f8c54226667241f","head":{"label":"breznak:acc_filter","ref":"acc_filter","sha":"8ef50f20a9d016d0196a7df41f8c54226667241f","user":{"login":"breznak","id":2166111,"avatar_url":"https://avatars.githubusercontent.com/u/2166111?v=3","gravatar_id":"","url":"https://api.github.com/users/breznak","html_url":"https://github.com/breznak","followers_url":"https://api.github.com/users/breznak/followers","following_url":"https://api.github.com/users/breznak/following{/other_user}","gists_url":"https://api.github.com/users/breznak/gists{/gist_id}","starred_url":"https://api.github.com/users/breznak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breznak/subscriptions","organizations_url":"https://api.github.com/users/breznak/orgs","repos_url":"https://api.github.com/users/breznak/repos","events_url":"https://api.github.com/users/breznak/events{/privacy}","received_events_url":"https://api.github.com/users/breznak/received_events","type":"User","site_admin":false},"repo":{"id":58466377,"name":"caer","full_name":"breznak/caer","owner":{"login":"breznak","id":2166111,"avatar_url":"https://avatars.githubusercontent.com/u/2166111?v=3","gravatar_id":"","url":"https://api.github.com/users/breznak","html_url":"https://github.com/breznak","followers_url":"https://api.github.com/users/breznak/followers","following_url":"https://api.github.com/users/breznak/following{/other_user}","gists_url":"https://api.github.com/users/breznak/gists{/gist_id}","starred_url":"https://api.github.com/users/breznak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breznak/subscriptions","organizations_url":"https://api.github.com/users/breznak/orgs","repos_url":"https://api.github.com/users/breznak/repos","events_url":"https://api.github.com/users/breznak/events{/privacy}","received_events_url":"https://api.github.com/users/breznak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/breznak/caer","description":"AER event-based framework, written in C, targeting embedded systems.","fork":true,"url":"https://api.github.com/repos/breznak/caer","forks_url":"https://api.github.com/repos/breznak/caer/forks","keys_url":"https://api.github.com/repos/breznak/caer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/breznak/caer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/breznak/caer/teams","hooks_url":"https://api.github.com/repos/breznak/caer/hooks","issue_events_url":"https://api.github.com/repos/breznak/caer/issues/events{/number}","events_url":"https://api.github.com/repos/breznak/caer/events","assignees_url":"https://api.github.com/repos/breznak/caer/assignees{/user}","branches_url":"https://api.github.com/repos/breznak/caer/branches{/branch}","tags_url":"https://api.github.com/repos/breznak/caer/tags","blobs_url":"https://api.github.com/repos/breznak/caer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/breznak/caer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/breznak/caer/git/refs{/sha}","trees_url":"https://api.github.com/repos/breznak/caer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/breznak/caer/statuses/{sha}","languages_url":"https://api.github.com/repos/breznak/caer/languages","stargazers_url":"https://api.github.com/repos/breznak/caer/stargazers","contributors_url":"https://api.github.com/repos/breznak/caer/contributors","subscribers_url":"https://api.github.com/repos/breznak/caer/subscribers","subscription_url":"https://api.github.com/repos/breznak/caer/subscription","commits_url":"https://api.github.com/repos/breznak/caer/commits{/sha}","git_commits_url":"https://api.github.com/repos/breznak/caer/git/commits{/sha}","comments_url":"https://api.github.com/repos/breznak/caer/comments{/number}","issue_comment_url":"https://api.github.com/repos/breznak/caer/issues/comments{/number}","contents_url":"https://api.github.com/repos/breznak/caer/contents/{+path}","compare_url":"https://api.github.com/repos/breznak/caer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/breznak/caer/merges","archive_url":"https://api.github.com/repos/breznak/caer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/breznak/caer/downloads","issues_url":"https://api.github.com/repos/breznak/caer/issues{/number}","pulls_url":"https://api.github.com/repos/breznak/caer/pulls{/number}","milestones_url":"https://api.github.com/repos/breznak/caer/milestones{/number}","notifications_url":"https://api.github.com/repos/breznak/caer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/breznak/caer/labels{/name}","releases_url":"https://api.github.com/repos/breznak/caer/releases{/id}","deployments_url":"https://api.github.com/repos/breznak/caer/deployments","created_at":"2016-05-10T14:04:19Z","updated_at":"2016-05-10T14:04:21Z","pushed_at":"2016-05-31T10:47:52Z","git_url":"git://github.com/breznak/caer.git","ssh_url":"git@github.com:breznak/caer.git","clone_url":"https://github.com/breznak/caer.git","svn_url":"https://github.com/breznak/caer","homepage":null,"size":31952,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"inilabs:master","ref":"master","sha":"f88626352829ed609cc52be19003d47c4527da61","user":{"login":"inilabs","id":15046222,"avatar_url":"https://avatars.githubusercontent.com/u/15046222?v=3","gravatar_id":"","url":"https://api.github.com/users/inilabs","html_url":"https://github.com/inilabs","followers_url":"https://api.github.com/users/inilabs/followers","following_url":"https://api.github.com/users/inilabs/following{/other_user}","gists_url":"https://api.github.com/users/inilabs/gists{/gist_id}","starred_url":"https://api.github.com/users/inilabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inilabs/subscriptions","organizations_url":"https://api.github.com/users/inilabs/orgs","repos_url":"https://api.github.com/users/inilabs/repos","events_url":"https://api.github.com/users/inilabs/events{/privacy}","received_events_url":"https://api.github.com/users/inilabs/received_events","type":"Organization","site_admin":false},"repo":{"id":58453010,"name":"caer","full_name":"inilabs/caer","owner":{"login":"inilabs","id":15046222,"avatar_url":"https://avatars.githubusercontent.com/u/15046222?v=3","gravatar_id":"","url":"https://api.github.com/users/inilabs","html_url":"https://github.com/inilabs","followers_url":"https://api.github.com/users/inilabs/followers","following_url":"https://api.github.com/users/inilabs/following{/other_user}","gists_url":"https://api.github.com/users/inilabs/gists{/gist_id}","starred_url":"https://api.github.com/users/inilabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inilabs/subscriptions","organizations_url":"https://api.github.com/users/inilabs/orgs","repos_url":"https://api.github.com/users/inilabs/repos","events_url":"https://api.github.com/users/inilabs/events{/privacy}","received_events_url":"https://api.github.com/users/inilabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inilabs/caer","description":"AER event-based framework, written in C, targeting embedded systems.","fork":false,"url":"https://api.github.com/repos/inilabs/caer","forks_url":"https://api.github.com/repos/inilabs/caer/forks","keys_url":"https://api.github.com/repos/inilabs/caer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inilabs/caer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inilabs/caer/teams","hooks_url":"https://api.github.com/repos/inilabs/caer/hooks","issue_events_url":"https://api.github.com/repos/inilabs/caer/issues/events{/number}","events_url":"https://api.github.com/repos/inilabs/caer/events","assignees_url":"https://api.github.com/repos/inilabs/caer/assignees{/user}","branches_url":"https://api.github.com/repos/inilabs/caer/branches{/branch}","tags_url":"https://api.github.com/repos/inilabs/caer/tags","blobs_url":"https://api.github.com/repos/inilabs/caer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inilabs/caer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inilabs/caer/git/refs{/sha}","trees_url":"https://api.github.com/repos/inilabs/caer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inilabs/caer/statuses/{sha}","languages_url":"https://api.github.com/repos/inilabs/caer/languages","stargazers_url":"https://api.github.com/repos/inilabs/caer/stargazers","contributors_url":"https://api.github.com/repos/inilabs/caer/contributors","subscribers_url":"https://api.github.com/repos/inilabs/caer/subscribers","subscription_url":"https://api.github.com/repos/inilabs/caer/subscription","commits_url":"https://api.github.com/repos/inilabs/caer/commits{/sha}","git_commits_url":"https://api.github.com/repos/inilabs/caer/git/commits{/sha}","comments_url":"https://api.github.com/repos/inilabs/caer/comments{/number}","issue_comment_url":"https://api.github.com/repos/inilabs/caer/issues/comments{/number}","contents_url":"https://api.github.com/repos/inilabs/caer/contents/{+path}","compare_url":"https://api.github.com/repos/inilabs/caer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inilabs/caer/merges","archive_url":"https://api.github.com/repos/inilabs/caer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inilabs/caer/downloads","issues_url":"https://api.github.com/repos/inilabs/caer/issues{/number}","pulls_url":"https://api.github.com/repos/inilabs/caer/pulls{/number}","milestones_url":"https://api.github.com/repos/inilabs/caer/milestones{/number}","notifications_url":"https://api.github.com/repos/inilabs/caer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inilabs/caer/labels{/name}","releases_url":"https://api.github.com/repos/inilabs/caer/releases{/id}","deployments_url":"https://api.github.com/repos/inilabs/caer/deployments","created_at":"2016-05-10T10:43:58Z","updated_at":"2016-05-13T19:56:57Z","pushed_at":"2016-05-31T11:24:33Z","git_url":"git://github.com/inilabs/caer.git","ssh_url":"git@github.com:inilabs/caer.git","clone_url":"https://github.com/inilabs/caer.git","svn_url":"https://github.com/inilabs/caer","homepage":null,"size":32185,"stargazers_count":3,"watchers_count":3,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inilabs/caer/pulls/2"},"html":{"href":"https://github.com/inilabs/caer/pull/2"},"issue":{"href":"https://api.github.com/repos/inilabs/caer/issues/2"},"comments":{"href":"https://api.github.com/repos/inilabs/caer/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/inilabs/caer/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/inilabs/caer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inilabs/caer/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/inilabs/caer/statuses/8ef50f20a9d016d0196a7df41f8c54226667241f"}}}}
{"actor":{"display_login":"breznak"}}