On Tuesday, 21 September 2021 at 04:40:21 UTC+2 linas wrote:
> On Mon, Sep 20, 2021 at 5:53 PM Adrian Borucki <[email protected]> wrote: > > > > Okay, if there is a concrete set of primitives you’d like to see > incorporated that would be useful to your project, that’s something I can > help with. > > Basically, what I had in mind in the beginning was that I can spare some > time to do some grunt work for this project. > > I don’t think I can offer anything beyond that at the moment. > > Ah .. silly me! I have a bad habit of assuming people are just like me! > > There's plenty of grunt work! OK. So to keep things specific, let's > say the project is to wrap Atomese around a tiny subset of OpenCV. > Does that sound reasonable? > Sure, I’ve already forked the repository below and started adding things, I don’t know if I’m going to have something working this week or if I get stuck, we’ll see. > > Steps: > *) Create github repo. I just did that: > https://github.com/opencog/vision and I gave you admin permissions on > it. > > *) Set up the conventional opencog repo boilerplate. A cut-n-paste of > the makefiles in opencog/atomspace-rocks might be easiest. Should I > ask you to do this, or should I? > > *) Create an atom types file & etc. a cut-n-paste of the types in > opencog/spacetime might be easiest. Its mostly boilerplate ... except > for the types themselves. > > *) For starters, we need to get still images into the system. I'm > thinking that this could be an ImageNode (or IMAGE_NODE <- NODE in the > types file). Corresponding to this type is a C++ class that > implements a wrapper to the suitable OpenCV analog. > > The ImageNode is a type of Node, the string would be the name of the > file (or URL) containing the image. The c++ constructor can either do > nothing, or maybe it can try to open that file. The C++ class would > have as private/protected members whatever is needed from > https://docs.opencv.org/4.5.3/d4/da8/group__imgcodecs.html which > seems to be how opencv reads images. So I guess a Mat which seems to > be the opencv handle to an image. > > *) Next, we need to do something with that image. So, I'm looking at > https://docs.opencv.org/4.5.3/d4/d86/group__imgproc__filter.html and > cv:blur() looks like a good place to start. So, we need an > ImageBlurLink which expects .. well, for now one parameter: a > NumberNode for the size, and the image to apply it to. So a typical > use would be (ImageBlurLink (ImageNode "/tmp/foo.jpg") (NumberNode > 20)) > > Calling the C++ method ImageBlureLink::execute() would apply the > filter to the image, and return a ... well, that's a good question. > It could return another ImageNode holding a handle to the mutated > image. But I don't want to place these "temporary results" into Atoms > .. they really need to be Values ... so it should return an > ImageValue, which is almost exactly the same thing as an ImageNode, > except that ... its a Value, not an Atom. > So .. how do Values work? They're just like Atoms, except you can't > store them in the atomspace. If you don't know values well, please > review the demo. > > https://github.com/opencog/atomspace/blob/master/examples/atomspace/values.scm > > > The StreamValue was invented to hold things like audio, video, and I > guess its OK to use it for static images, too. See > > https://github.com/opencog/atomspace/blob/master/examples/atomspace/stream.scm > > > It seems like streams correspond to a concept of the same name in some other programming languages (or to the concept named “generators”). That should mean that if we have a list of image files to process, then we can iterate through that, getting the “next” image each time. The RandomStream should probably be renamed to something more descriptive, so that it is clear it produces a specific data type (the lack of name spaces in Atomese hurts here but that’s a side note). > Just to confuse things, I should mention three more demos:: > > https://github.com/opencog/atomspace/blob/master/examples/atomspace/formulas.scm > > and > https://github.com/opencog/atomspace/blob/master/examples/atomspace/flows.scm > and > https://github.com/opencog/atomspace/blob/master/examples/atomspace/flow-formulas.scm > > ... Those examples all use TruthValues to do their stuff; the general > idea that something similar would be used to route around video and > sound. But maybe we can ignore these for now. > > I don't know how well you know the atomspace internals ... I'm hoping > the above is not overwhelming. It does require some thinking. I do > expect you to get confused. I do expect to give you wrong suggestions > from time to time. I expect I'll have to jump in and debug some code > sometimes... Values were invented for this kind of stuff, but using > them for audio, video would be new. > > The general idea is that the ImageValues will hold a handle to the > image being processed, and the ImageBlurLink, and other things of that > kind specify the kinds of transformations to be applied to the image. > The actual images are never in the atomspace, only the abstract > processing tree, and a way of hooking that tree to the image(s) to be > processed. > *) Once this most basic demo works, the rest is just plain easy -- its > just cut-n-paste from this basic example, to add more filter types. > I'll have to crawl through the OpenCV docs to pick out two or three > more must-have ops. > > -- Linas > > -- > Patrick: Are they laughing at us? > Sponge Bob: No, Patrick, they are laughing next to us. > -- You received this message because you are subscribed to the Google Groups "opencog" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/4e802727-645b-4f34-b5c6-1814bc5b6550n%40googlegroups.com.
