Question: I'm wondering what the best way to go about developing a rails application with the following features:

* All of the data comes from a SOAP request to a 3rd party
* A background task will make this soap request every ~10s
* The background task will parse the response and then update an ActiveRecord model accordingly
* The data isn't written to a database at all, if the app fails, when we start it back up the data will come from the soap request again
* Users will make a request to the app which will simply show data in the model (i.e. from the soap request).

The idea is to avoid making the SOAP request for every single user as the data won't change that frequently. Not using a database avoids reading and writing of data that only ever comes from the request anyway.

I imagine that all of this can be completely quite simply with a few gems but I've had a bit of trouble sorting through what meets my requirements and what doesn't.

Thanks

Answer: 
I recommend you to use the C++ functions and not the old C style functions.

The most efficient way to write to pixels is the following.

```
   cv::Mat frame;

   // load your img to your Mat

   uchar* p = frame.ptr(row); // returns a row pointer
   p[column] = x; // accesses value in the given column

```

One thing to note is that you might have more columns than you have pixel columns, e.g. on a 3 channel image you have 3 times the number of actual pixel columns you can access.

For more information on different ways to iterate over pixels, check [this](http://opencv.itseez.com/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#howtoscanimagesopencv) tutorial.
You need to get a pointer to the data field of the structure.

(C API) The IplImage structure has a char\* field called data. Access `(your_type*)image->data` for the first element, and then use it like a regular C 1D array, but be careful to use the field stepWidth to jump from a line to the next (because lines of data may be aligned on multiples of 16 bits for memory access optimization).

(C++ API) Use `T* cv::Mat::ptr<T>(int i)` to get a pointer to the first element of the line you want to access. Then use as a regular C++ 1D array.

This should be the faster access pattern (see the book OpenCV2 Cookbook for a comparison of the different access patterns).