Ask Your Question
0

Bus error when converting colors

asked 2018-09-20 17:56:27 -0500

cwalton gravatar image

updated 2018-09-21 12:53:32 -0500

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...

edit retag flag offensive close merge delete

Comments

that's not enough information. please add the exact errormsg.

also, the code you show isn't helpful to diagnose anything here.

berak gravatar imageberak ( 2018-09-21 00:27:01 -0500 )edit

Ok I revised my post to give a link to my github repository.

cwalton gravatar imagecwalton ( 2018-09-21 12:54:44 -0500 )edit

i'm afraid, noone here will get a jetson TK AND clone your github, to reproduce the error.

berak gravatar imageberak ( 2018-09-21 12:56:12 -0500 )edit
1

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 gravatar imagecwalton ( 2018-09-21 13:20:46 -0500 )edit

@cwalton, don't get it wrong, you got all my sympathy, i'm only stumped, at how to make this "reproducable"

berak gravatar imageberak ( 2018-09-21 13:24:40 -0500 )edit

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.

cwalton gravatar imagecwalton ( 2018-09-21 13:34:33 -0500 )edit

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,

cwalton gravatar imagecwalton ( 2018-09-21 20:38:21 -0500 )edit

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"

berak gravatar imageberak ( 2018-09-22 00:08:50 -0500 )edit

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.

berak gravatar imageberak ( 2018-09-22 00:19:01 -0500 )edit

Hmmm..... all the code in visionpipeline was auto generated by GRIP

cwalton gravatar imagecwalton ( 2018-09-22 11:10:49 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2018-09-23 16:28:22 -0500

cwalton gravatar image

OK this issue has been resolved colors are straightened up thank you so much Berak for your help issue with everything, seemed to be the pointers that were being used by the automatically generated grip code. We took all the pointers out and did it properly and the camera issue resolved itself probably some kind of driver glitch. Can’t tell you how much I appreciate your help as we would’ve not got past that bus error with out you. And now will know how to help someone else in our robotics community who may have the same issue

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-09-20 17:56:27 -0500

Seen: 433 times

Last updated: Sep 21 '18