OpenCV and MicroMacro

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Message
Author
User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#21 Post by Administrator » Mon Jun 15, 2015 11:48 pm

Good stuff. Make another reply once you get it all compiled and I'll add it to the main site.

Did you fork my repository? If so, what's the URL?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#22 Post by BlubBlab » Wed Jun 17, 2015 9:28 am

I simple merge with WinMerge the whole time maybe I should make repository. I did once for the Bot-Framework but haven't the time to actually use it.

Anyway what I did was I moved the winsock.h into the wininclude.h and made sure that I haven't any other windows.h around this was what made the most trouble besides recursive definitions and I also renamed your Socket class to PSocket to avoid name conflicts.

Today I found a missing 'static' again with the logs but after I added it it worked.

What I have to do I add somehow at least : "with OpenCV extension" to the Version somehow and currently I have a buffer overflow when use your http.download.lua for testing. I'm not sure when I through with finding the problem.

--removed--
Edit2:
After watching the runInit function it seems I end here

Code: Select all

int failstate = lua_pcall(lstate, nargs, 0, stackbase+1);
I suspect it has maybe something to do with arguments

Code: Select all

local connected,err = socket:connect(host, 80);
print("Connected:", connected, err);
but we return only 1 argument if success

Code: Select all

	luaL_getmetatable(L, LuaType::metatable_socket);
	lua_setmetatable(L, -2);

	return 1;
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#23 Post by Administrator » Wed Jun 17, 2015 11:12 am

That's OK. When you return in a C++ callback, Lua will pop anything down to keep things on track.

If you can narrow it down to maybe ~10 lines of Lua code that is causing a buffer overrun, I can fix it. I do know that the networking stuff does still need some work and likely has a number of issues. As for the static variable with the logger, do you have any more information so I can make the correction on my end?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#24 Post by BlubBlab » Wed Jun 17, 2015 4:39 pm

took me some while but I found the reason:

Code: Select all

--print("Socket:", socket);
Printing userdata out I don't think that is a good idea. I think you forgot to mark it as such.
This caused the buffer overflow. I still have no connection but I suspect I must make the firewall free on foot.
(The line seems like the typical last minute change :roll: )

Edit: okay 32% download than again buffer overflow *wurg*

Edit2: After a few test it suddenly works. :shock: :shock:
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#25 Post by Administrator » Wed Jun 17, 2015 5:16 pm

Here's what printing a socket does:

Code: Select all

int Socket_lua::tostring(lua_State *L)
{
	Socket *pSocket = *static_cast<Socket **>(lua_touserdata(L, 1));
	char buffer[64];
	slprintf(buffer, sizeof(buffer), "Socket (0x%p)", pSocket->socket);

	lua_pushstring(L, buffer);
	return 1;
}
Script> exec

Entering interactive mode. Enter 'exit' to quit.
> print( network.socket() );
Socket (0x00000344)
I can't see any valid reason that should ever get anywhere close to 64+ characters, but even if it did slprintf() should prevent it from doing anything bad. Have you modified this function?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#26 Post by BlubBlab » Wed Jun 17, 2015 5:59 pm

I found what it was your are practically returning that buffer from that function.
After that call is over there is no buffer any more, so make it also static.

But here it is but I'm still looking of a way to change the version.
http://www.mediafire.com/download/5zh6n ... 64-bit.zip
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#27 Post by Administrator » Wed Jun 17, 2015 7:04 pm

I found what it was your are practically returning that buffer from that function.
After that call is over there is no buffer any more, so make it also static.
Can you elaborate? It is not returning any buffer. lua_pushstring() creates its own copy of the string, so it should not be causing any issues of the sort. Or did you mean slprintf()?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#28 Post by BlubBlab » Wed Jun 17, 2015 7:24 pm

It run complete through tostring the other possibility is that there was a missing NULL termination.

lua_pushstring


const char *lua_pushstring (lua_State *L, const char *s);

Pushes the zero-terminated string pointed to by s onto the stack. Lua makes (or reuses) an internal copy of the given string, so the memory at s can be freed or reused immediately after the function returns.

Returns a pointer to the internal copy of the string.

If s is NULL, pushes nil and returns NULL.
When I look at this it could be also incompatible types, it is just mystic.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#29 Post by Administrator » Wed Jun 17, 2015 7:33 pm

slprintf() should enforce a NULL-terminator. I've changed the code to attempt to manually create a buffer overflow, and the code properly protected against it. Have you modified either the Socket_lua::tostring() or slprintf() functions? Have you tried changing the %p to %x?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#30 Post by BlubBlab » Thu Jun 18, 2015 2:17 pm

No but I think it is possible that VS compiler did something that it shouldn't since I have all optimization on in the compiler.
So I have add " with OpenCV " in the version .

http://www.mediafire.com/download/lpzpq ... 64-bit.zip

That should work.

+ added socket API from admin
+ update Open CV library to release version.
+ some minor changes about directory work also admin.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#31 Post by Administrator » Thu Jun 18, 2015 2:41 pm

Did you use the slprintf() that I wrote, or does your compiler include its own copy? That could explain it.

There's a few minor issues with your release:
  • It does not include license.txt; this is legally required
  • You should rename config.lua to config.default.lua; config.lua will be generated out of it when first run and if something goes wrong the user can just delete it to reset it to default.
  • You probably don't want to include your scripts.
  • You shouldn't include logs, as they could potentially contain sensitive information.
  • You should include version number in the zip filename.
I wrote a script to bundle up a release for me; it handles all of those things (plus more) automatically. I'll include my script for you to use; it is a Lua script but is not intended to be run in MicroMacro itself, but in the normal Lua interpreter.

I went ahead and fixed up your package and put it on the main page.
Attachments
gen.release.lua
(1.99 KiB) Downloaded 940 times

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: OpenCV and MicroMacro

#32 Post by beanybabe » Thu Jun 18, 2015 3:49 pm

This sounds like it would be fun to use with some cam's and a pea shooter. Have cams watch for bugs, flys etc then pop a pea at them.
Your so lucky to have started learning this language early its so hard for me to figure out every bit I code. I need lots of examples to complete a project.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#33 Post by BlubBlab » Thu Jun 18, 2015 4:30 pm

The licence.txt went somehow away :?:
The logs I noticed it seems you load a version down before I removed them
The scripts are there for tests and as fist steps examples at the same times.

Maybe I move some stuff also in libs the next time.

About : slprintf() I will take a look but it works fine for now , there was a collision with Socket which I solved with renaming , there is also a collision with Mutex which on top has also the same header name but seems no problem.

I think Tools need a Readme in the next version

http://www.mediafire.com/download/7fs9r ... 17_x64.zip
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#34 Post by BlubBlab » Thu Jun 18, 2015 4:33 pm

beanybabe wrote:This sounds like it would be fun to use with some cam's and a pea shooter. Have cams watch for bugs, flys etc then pop a pea at them.
Your so lucky to have started learning this language early its so hard for me to figure out every bit I code. I need lots of examples to complete a project.
I had the idea what could micromacro do with object recognition ? Pick up Sykpe when a call comes in and activate something when it sees your face.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#35 Post by Administrator » Thu Jun 18, 2015 5:18 pm

BlubBlab wrote:there was a collision with Socket which I solved with renaming , there is also a collision with Mutex which on top has also the same header name but seems no problem
I moved those both into the MicroMacro namespace which should prevent collisions. Is that not the case, or perhaps you weren't caught up to that commit?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#36 Post by BlubBlab » Thu Jun 18, 2015 5:43 pm

I didn't got any error from the Mutex I think it is possible the problem from the Socket was because I moved the winsocket2.h include into the wininclude.h.


Code: Select all

using namespace std;

struct PSocket
	{
		SOCKET socket;
		HANDLE hThread;
		int protocol;
		bool connected;
		bool open;

		std::queue<Event> eventQueue;
		std::queue<std::string> recvQueue;
		Mutex mutex;
	};
Okay they aren't exactly the same name Socket(SOCKET)but it is confusing to read. I changed it because the whole include winsock2.h before windows.h because of wrong include orders you will have redefine errors. It was just a possibility which I had to eliminate to find the include problem.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#37 Post by BlubBlab » Fri Jun 19, 2015 7:18 am

slprintf() is your definition.

But I have an idea why after I saw this:

Code: Select all

namespace LuaType
	{
		extern const char *metatable_socket;
	}
Everytime I use a var which includes an extern var I must make it static in VS that was also the reason for the changes to static in the main.cpp.

It is very indirect in this case but the best idea I have.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5314
Joined: Sat Jan 05, 2008 4:21 pm

Re: OpenCV and MicroMacro

#38 Post by Administrator » Fri Jun 19, 2015 11:04 am

Yeah, that could be related. It's very strange though. That's an extern variable that is declared at global scope, and shouldn't need to be static because, well, it's global! I'm going to chalk this one up to Microsoft's non-standard compiler causing issues.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#39 Post by BlubBlab » Sat Aug 01, 2015 5:40 pm

*Merge with current version of MM2*


Check list:
-licence
-removed logs
-add manifest
-removed plugins directory
-updated source code in src (repository is also updated)

-add README to directory tools
-add a forgotten tool

Micromacro 2 with opencv 64-bit version http://www.mediafire.com/download/gdvex ... 05_x64.zip

Micromacro 2 with opencv 32-bit version http://www.mediafire.com/download/3on7x ... 05_x86.zip

Changes :
-added system.yield() for multi-threading
-updated to Lua 5.3.1
-added all the other new stuff from admin like press enter to choose your script from a menu :shock:
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: OpenCV and MicroMacro

#40 Post by BlubBlab » Sun Aug 09, 2015 2:56 pm

*Merge with current version of MM2*


Check list:
-licence
-removed logs
-add manifest
-removed plugins directory
-updated source code in src

64-bit version: http://www.mediafire.com/download/dck9w ... 14_x64.zip
32-bit version: http://www.mediafire.com/download/exosl ... 14_x86.zip

changes:
- fix a bug with the manifest it should work now.
- recompiled the entire project PDcurse libs were out-dated behind everything (compiler: NO I don't want that.)
- added process.resume(Handle) , process.suspend(Handle) , (a suspended process will now first resumed)
(please don't try that with your desktop = the need to disconnect you PC)
- added ReadMemoryRepeat as part of an exception handling inside MM2.
- added handling of directory with white space per menu./FIX
- updated to git version of OpenAL32 (basically 1.17) was necessary because of otherwise compatibly problems with VS 2015

TODO:
- config about weather ReadMemoryRepeat and resumse/suspend is used.

Maybe add later:
- an algorithm from my Bachelor work to identify simple object on the numbers of corners.
- an interface for a driver communication and installation.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests