I am trying to use multimedia toolkit to get image data. However factory->CreateInstance(config) functions gives memory error. I could not figure out what causes it.

This page might be helpful for you –

https://doc.developer.milestonesys.com/html/index.html?base=mmtkhelp/index.html&tree=tree_2.html

You might have an inspiration from Tutorial in the page.