Re: OpenCV and complex objects in webworkers
Thank you. After proper serialization everything works fine. пятница, 11 августа 2017 г., 10:29:47 UTC+3 пользователь ilia.g...@gmail.com написал: > > Hi, > I am practicing to call webworker inside C++ with emscripten_call_worker() > and I want to pass complext object, lile > class Object > { > std::vector bytes; > std::string name; > cv::Mat image; > }: > > Before passing I use memcpy to copy memory to char and pass it, but it > looks like web worker loose some parts of bytes. When I try to get access > to them in workers. Maybe I should add some flags, or I just cannot pass > complex objects to worker? > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: OpenCV and complex objects in webworkers
The upcoming solution for this type of problem is the SharedArrayBuffer specification, which allows Web Workers to share data and pointers directly. Though emscripten_call_worker() is not designed to work with SharedArrayBuffer. You can try creating multiple threads with the -s USE_PTHREADS=1 build mode, and run in a browser that supports SharedArrayBuffer, and then use the pthreads API to create multiple threads that can access pointers to classes like native multithreading does. perjantai 11. elokuuta 2017 Alon Zakai kirjoitti: > Yes, objects like that won't automatically work properly with > emscripten_call_worker. That method just receives a pointer and a size, and > it copies those bytes. In this case, the std::vector (and maybe string) > refer to bytes allocated on the heap, and not inside the object itself. So > you'd need to make sure those are copied as well. > > On Fri, Aug 11, 2017 at 12:29 AM, > wrote: > >> Hi, >> I am practicing to call webworker inside C++ with >> emscripten_call_worker() and I want to pass complext object, lile >> class Object >> { >> std::vector bytes; >> std::string name; >> cv::Mat image; >> }: >> >> Before passing I use memcpy to copy memory to char and pass it, but it >> looks like web worker loose some parts of bytes. When I try to get access >> to them in workers. Maybe I should add some flags, or I just cannot pass >> complex objects to worker? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "emscripten-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to emscripten-discuss+unsubscr...@googlegroups.com >> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to emscripten-discuss+unsubscr...@googlegroups.com > > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: OpenCV and complex objects in webworkers
Yes, objects like that won't automatically work properly with emscripten_call_worker. That method just receives a pointer and a size, and it copies those bytes. In this case, the std::vector (and maybe string) refer to bytes allocated on the heap, and not inside the object itself. So you'd need to make sure those are copied as well. On Fri, Aug 11, 2017 at 12:29 AM, wrote: > Hi, > I am practicing to call webworker inside C++ with emscripten_call_worker() > and I want to pass complext object, lile > class Object > { > std::vector bytes; > std::string name; > cv::Mat image; > }: > > Before passing I use memcpy to copy memory to char and pass it, but it > looks like web worker loose some parts of bytes. When I try to get access > to them in workers. Maybe I should add some flags, or I just cannot pass > complex objects to worker? > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to emscripten-discuss+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.