Bus error when converting colors
I get a bus error that I cannot figure out. It crashes in this section of the code when it tries to convert the color. It is in visionpipeline.cpp
cv::cvtColor(input, out, cv::COLOR_BGR2HLS); This is the line where it stops and I get a bus error
Here is a github link to all the code: https://github.com/isaiahwalton/Jetso...
that's not enough information. please add the exact errormsg.
also, the code you show isn't helpful to diagnose anything here.
Ok I revised my post to give a link to my github repository.
i'm afraid, noone here will get a jetson TK AND clone your github, to reproduce the error.
Ok sorry. Forgive me as I am a mom who has been thrust into the position of programming mentor and I’m helping out my 15-year-old son who is been thrust into the position of head programmer for world championship robotics team. I have a little to no experience and we are drinking through the fire hose of C++ and are now drinking from the firehose of vision processing. Forgot that you would have to clone it from github. This error has stumped us for a few days. It might be a byte alignment issue.
@cwalton, don't get it wrong, you got all my sympathy, i'm only stumped, at how to make this "reproducable"
Ha ha I wasn’t thinking about anybody actually trying to duplicate it I thought somebody might just take a look at the code and see if they could see something off hand that we have done wrong.
Ok we ran gdb debugging and got this error:
Program received signal SIGBUS, Bus error. 0x0000b5d2 in __gnu_cxx::__exchanged_and_add (__mem=0x2, __val=-1) at /usr/include/c++/4.8/ext/atomicity.h:49 49 { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
So it appears that the data type is not byte aligned. We ran some code to determine if was aligned and it said it wasn’t. Problem is that we don’t know how to align it in the CV::mat class. When we change it to a local variable it works, but of course we can’t have that. Any help you can give would be hugely appreciated. We are completely stuck,
well, i had a quick look at your code, and found, that you are passing around pointers to cv::Mat, e.g.here
don't do that ! cv::Mat is already a refcounted smartpointer around the pixels, if you use pointers to that , you defeat it's purpose, and inevitably have aliases, dangling dead pointers and memleaks.
use a plain copy (it's only 60 or so bytes) or a reference instead, NOT pointers.
please also do NOT use IplImages or anything from the defunkt C-api
and well, to outsource the whole gstreamer capture code & "hack some tiny things in" -- that's at least "exotic"
can you reproduce it with a simple minimal prog, that just loads a cv::Mat from disk, and convert it to hls ? next step might be, to feed it through your whole processing pipeline.
again, my guess is, you're doing something invalid in the capture part.
Hmmm..... all the code in visionpipeline was auto generated by GRIP
yea, i've seen, you re-use it in other repo's ;)
(but GRIP is new to me !)
again, divide & conquer.
there are a couple of jetson users, and i somehow don't see anyone else having this problem.
That’s why this is stumping us so much. We are going to rewrite some of the code without the pointers as was suggested and see if that cleans things up a bit. We tried to just use align ptr(). Didn’t work. If there any that use jetson that could help???
there's ; YAGNI (no, you don't need another pipeline (you can't control)
again, that GRIP thing (does it have issues / pr's ?, do you you see it being actively maintained ?) might be your main cause of trouble.
start at where the silly Iplimage is creeeping into your code.
again -- try to load an image and display it (NOT using any of that GRID shite)
Using grip because it makes setting up filters easier. So it looked like taking out all the pointers helped quite a bit and got rid of the bus error. So now we’re down to things that are more understandable. The colors are weird on our camera images. We think it has to do with using IplImage to cv::mat. We are trying to convert it since we are using gstreamer to bring the image in and it is lplimage but don’t know how/if to do that
I think it’s now converted OK but the colors coming in from G streamer into CV mat are weird. Even the initial camera image is mixed up and the colors change when we rerun it!