{"action":"closed","issue":{"url":"https://api.github.com/repos/Itseez/opencv/issues/6288","repository_url":"https://api.github.com/repos/Itseez/opencv","labels_url":"https://api.github.com/repos/Itseez/opencv/issues/6288/labels{/name}","comments_url":"https://api.github.com/repos/Itseez/opencv/issues/6288/comments","events_url":"https://api.github.com/repos/Itseez/opencv/issues/6288/events","html_url":"https://github.com/Itseez/opencv/issues/6288","id":141595631,"number":6288,"title":"cv::FileStorage de-serialization of std::vector<cv::KeyPoint> fails","user":{"login":"rwiesen","id":15102484,"avatar_url":"https://avatars.githubusercontent.com/u/15102484?v=3","gravatar_id":"","url":"https://api.github.com/users/rwiesen","html_url":"https://github.com/rwiesen","followers_url":"https://api.github.com/users/rwiesen/followers","following_url":"https://api.github.com/users/rwiesen/following{/other_user}","gists_url":"https://api.github.com/users/rwiesen/gists{/gist_id}","starred_url":"https://api.github.com/users/rwiesen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwiesen/subscriptions","organizations_url":"https://api.github.com/users/rwiesen/orgs","repos_url":"https://api.github.com/users/rwiesen/repos","events_url":"https://api.github.com/users/rwiesen/events{/privacy}","received_events_url":"https://api.github.com/users/rwiesen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Itseez/opencv/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/Itseez/opencv/labels/category:%20core","name":"category: core","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-17T14:16:09Z","updated_at":"2016-04-13T07:51:48Z","closed_at":"2016-04-13T07:51:48Z","body":"### OpenCV version and host system\r\n- OpenCV version: git b3ac274617beb8e54c8bfebcb141090a57165ea2, but unchanged in HEAD\r\n- Host OS: Windows 7\r\n\r\n### In which part of the OpenCV library you got the issue?\r\n- core/types.hpp\r\n\r\n### Expected behaviour\r\n- Take a cv:KeyPoint kp with kp.octave = 1 and kp.class_id = -1\r\n- serialize this keypoint as part of a std::vector to a cv::FileStorage\r\n- the entry in the file correctly shows \"..., 1, -1, ...\"\r\n- deserialize the keypoint\r\n- kp.octave is 1\r\n- kp.class_id is -1\r\n\r\n### Actual behaviour\r\nafter deserialization:\r\n- kp.octave is 1073741824 (a 1.0f reinterpreted as int)\r\n- kp.class_id is -1082130432 (a -1.0f reinterpreted as int)\r\n\r\n### Additional description\r\ncv::Keypoint instances with octave or class_id != 0 are not deserialized correctly.\r\n\r\nThe cv::KeyPoint class declares octave and class_id as int (in addition to the five float members), but DataType<KeyPoint> declares a vector of seven floats. When read in, the integer values are converted to float in cvReadRawDataSlice(), but interpreted as int in the datastructure.\r\n\r\n### Code example to reproduce the issue / Steps to reproduce the issue\r\n```.cpp\r\n// File was written with:\r\n// cv::FileStorage fs( featuresFile, cv::FileStorage::WRITE );\r\n// cv::write( fs, \"keypoints\", keypoints );\r\n// fs.release();\r\n\r\ncv::FileStorage fs;\r\nstd::vector<cv::KeyPoint> keypoints;\r\n\r\nfs.open( featuresFile, cv::FileStorage::READ );\r\nfs[\"keypoints\"] >> keypoints;\r\n```"}}