lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


* Michal Kottman:

> I have a similar problem - I am currently creating a binding for the
> OpenCV library. This solution cannot be applied in my case, because I
> cannot (and do not want to) modify the library. A common pattern in
> OpenCV is this (this is how I imagine the binding):
>
> while not finished do
> 	local img = cv.RetrieveFrame(cam) -- retrieves image from cam
> 	-- do some processing
> end

Would it be possible to write this instead?

  while not finished do
 	local img = cv.RetrieveFrame(cam) -- retrieves image from cam
  	-- do some processing
        img:release()
  end

This doesn't seem to be too onerous to me.

(In exception handlers, you should perform full collections if you
follow this style, but that shouldn't result in performance problems
as long as exceptions are rare.)