GitHub PullRequestReviewCommentEvent at 2014-05-26 23:48:30
Repository: shogun
Actor: lambday
Payload: {"comment":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/13058916","id":13058916,"diff_hunk":"@@ -0,0 +1,109 @@\n+#include <shogun/lib/config.h>\n+#ifdef HAVE_OPENCV\n+\n+#ifndef __CV2SGMATRIXFACTORY_H__\n+#define __CV2SGMATRIXFACTORY_H__\n+\n+\n+#include <opencv2/highgui/highgui.hpp>\n+#include <shogun/lib/SGMatrix.h>\n+#include <shogun/features/DenseFeatures.h>\n+\n+namespace shogun{\n+\n+enum CV2SGOptions {CV2SG_CONSTRUCTOR, CV2SG_MANUAL, CV2SG_MEMCPY};\n+\n+template <typename T> struct CV2SGTypeName;\n+\n+template<> struct CV2SGTypeName<uint8_t>\n+{\n+\tstatic const int get(){return 0;}\n+};\n+\n+template<> struct CV2SGTypeName<int8_t>\n+{\n+\tstatic const int get(){return 1;}\n+};\n+\n+template<> struct CV2SGTypeName<uint16_t>\n+{\n+\tstatic const int get(){return 2;}\n+};\n+\n+template<> struct CV2SGTypeName<int16_t>\n+{\n+\tstatic const int get(){return 3;}\n+};\n+\n+template<> struct CV2SGTypeName<int32_t>\n+{\n+\tstatic const int get(){return 4;}\n+};\n+\n+template<> struct CV2SGTypeName<float32_t>\n+{\n+\tstatic const int get(){return 5;}\n+};\n+\n+template<> struct CV2SGTypeName<float64_t>\n+{\n+    static const int get(){return 6;}\n+};\n+\n+class CV2SGMatrixFactory\n+{\n+\tpublic:\n+\t\n+\tCV2SGMatrixFactory();\n+\t\n+\tvirtual ~CV2SGMatrixFactory();\n+\t\n+\ttemplate <typename T> static SGMatrix<T> getMatrix(cv::Mat, CV2SGOptions=CV2SG_CONSTRUCTOR);\n+};\n+\n+template<typename T> SGMatrix<T> CV2SGMatrixFactory::getMatrix(cv::Mat cvMat, CV2SGOptions option)\n+{\n+\tint nRows=cvMat.rows;\n+\tint nCols=cvMat.cols;\n+\tconst int myType = CV2SGTypeName<T>::get();\n+\tcvMat.convertTo(cvMat,myType);\n+\tswitch (option)\n+\t{\n+\n+\t\tcase CV2SG_CONSTRUCTOR:\n+\t\t{\n+\t\t\tSGMatrix<T> sgMat((T*)cvMat.data, nRows, nCols, false);\n+\t\t\treturn sgMat;\n+\t\t}\n+\n+\t\tcase CV2SG_MANUAL:\n+\t\t{\n+\t\t\tSGMatrix<T> sgMat(nRows, nCols);\n+\n+\t\t\tfor(int i=0; i < nRows; i++)","path":"src/shogun/lib/OpenCV/CV2SGMatrixFactory.h","position":83,"original_position":83,"commit_id":"20576607f6669dd4198b23c2d5649a268e6c98e7","original_commit_id":"20576607f6669dd4198b23c2d5649a268e6c98e7","user":{"login":"lambday","id":3088401,"avatar_url":"https://avatars.githubusercontent.com/u/3088401?","gravatar_id":"5d358603dc69f0f3cef1026992254537","url":"https://api.github.com/users/lambday","html_url":"https://github.com/lambday","followers_url":"https://api.github.com/users/lambday/followers","following_url":"https://api.github.com/users/lambday/following{/other_user}","gists_url":"https://api.github.com/users/lambday/gists{/gist_id}","starred_url":"https://api.github.com/users/lambday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lambday/subscriptions","organizations_url":"https://api.github.com/users/lambday/orgs","repos_url":"https://api.github.com/users/lambday/repos","events_url":"https://api.github.com/users/lambday/events{/privacy}","received_events_url":"https://api.github.com/users/lambday/received_events","type":"User","site_admin":false},"body":"Also, no space between `i` and `<` and `<` and nRows. and could you please use `num_rows` instead of `nRows` or something like that? No CamelCase I mean :)","created_at":"2014-05-26T23:48:30Z","updated_at":"2014-05-26T23:48:30Z","html_url":"https://github.com/shogun-toolbox/shogun/pull/2250#discussion_r13058916","pull_request_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2250","_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/13058916"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/2250#discussion_r13058916"},"pull_request":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2250"}}}}