Exporting bounding box coordinates to i2c

Does anybody know how to do the above? I’ve seen a basic i2c tutorial on jetson hacks, but how do I access bounding box data to send? Thanks!

No really understand the problem.

ok …. I’ve got the Jetson producing bounding boxes around objects using the onboard camera by following the tutorial here: [url]https://github.com/dusty-nv/jetson-inference[/url].

I’ve also found a basic I2C tutorial here which can send data via I2C to a LED display: [url]https://www.jetsonhacks.com/2018/07/25/i2c-nvidia-jetson-tx2-development-kit/[/url]

Now I need to send the coordinates of the bounding boxes detected to the outside world (eg an LED display) so I can eventually steer my WEEDINATOR [url]https://hackaday.io/project/53896-weedinator-2018[/url] machine along beds of vegetables.

No replies! ???

I run this in terminal:
sudo ~/jetson_clocks.sh && cd jetson-inference/build/aarch64/bin && ./detectnet-camera coco-dog

Then get this printed in terminal:
0 bounding boxes detected
0 bounding boxes detected
0 bounding boxes detected
0 bounding boxes detected
1 bounding boxes detected
bounding box 0 (428.906250, 438.679688) (500.812500, 510.679688) w=71.906250 h=72.000000
draw boxes 1 0 0.000000 200.000000 255.000000 100.000000
0 bounding boxes detected
0 bounding boxes detected

…. And I want to access the data eg. 428.906250 and w=71.906250
What file prints this data? What’s it called and where does it live? What’s the name of the variables used?

Thanks !!!

I found out yesterday from Jim at Jetsonhacks that the detectnet-camera.cpp file provides the boundary box information. Thank you Jim!

Now I need to alter that file to include an I2C file and re-make it with it’s dependancies in such a way that I don’t completely destroy my system. Baring in mind that I don’t really know what I am doing, can anybody help at all?

Thanks!

Hi,

You can check Jetson_inference code for more details.
The object detection pipeling works like this:

Camera → Pre-process → TensorRT(DL inference) → Post-process

In post-process, we interpret network output by checking the coverage and bbox blob.
You can find here for the DetectNet model design.

So please try to output the boundingBoxes array and feed it into the place you want.
https://github.com/dusty-nv/jetson-inference/blob/master/detectNet.cpp#L414

Thanks.

Thanks for reply … Seems like I can use either detectNet.cpp or detectnet-camera.cpp to achieve bounding box coordinate export to I2C.

It also seems like there is a module called ‘jetson-inference’ which has it’s own make files.

To keep it simple, say I wanted to change to change this line:

‘printf(“%i bounding boxes detected\n”, numBoundingBoxes);’

to:

‘printf(“%i bouncing boxes detected\n”, numBoundingBoxes);’

How do I re-make jetson-inference ??? for this to take effect.

Is this it here:

$ cd jetson-inference/build
$ make

???
I’m not a Linux expert - I’m sure it’s really simple for the person who does know how to do it !!!

I tried it anyway … What harm can it do? … And now I have bouncing boxes! YAY !

Next step is to try and get the ‘displayExample.cpp’ from Jim at Jetsonhacks file working within the ‘jetson-inference’ module.

I2C Files are here: GitHub - paddygoat/JHLEDBackpack: I2C interface for Adafruit LED Backpack for 7 segment display
jetson-inference files here: GitHub - dusty-nv/jetson-inference: Hello AI World guide to deploying deep-learning inference networks and deep vision primitives with TensorRT and NVIDIA Jetson.

I’m guessing that I should paste the relevant files into a suitable directory within jetson-inference and edit one of the make files to get it to compile?

Maybe within these lines of code within jetson-inference/detectnet-camera/CMakeLists.txt:

file(GLOB detectnetCameraSources *.cpp)
file(GLOB detectnetCameraIncludes *.h )

cuda_add_executable(detectnet-camera ${detectnetCameraSources})
target_link_libraries(detectnet-camera nvcaffe_parser nvinfer jetson-inference)

Anybody got any ideas at all? … Thanks!

I’m struggling to understand the makefile structure in jetson-inference. How do I incorporate the JHLEDBackpack files into jetson-inference such that it ‘makes’ and ultimately displays bounding box info ???

NB. I know the screen is too small but it doesn’t matter.

Hi,

Check CMakeLists.txt located at the detectnet-camera folder:

file(GLOB detectnetCameraSources *.cpp)
file(GLOB detectnetCameraIncludes *.h )

It by default compiles all the .cpp file inside the folder.
You will need to include the jasonhacks function into the detectnet-camera.cpp.
Add your handling code and recompile it with make.

Thanks.

Thanks - that makes sense now.
Just need to test it - waiting for 5v - 3.3v logic level shifter to arrive.

It’s working !!!

… But not writing to I2c.

The code compiles ok, but I’m not sure if the .cpp file is in the right place, see below:

/*
 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <time.h>

#include "gstCamera.h"

#include "glDisplay.h"
#include "glTexture.h"

#include <stdio.h>
#include <signal.h>
#include <unistd.h>

#include "cudaMappedMemory.h"
#include "cudaNormalize.h"
#include "cudaFont.h"

#include "detectNet.h"
#include "JHLEDBackpack.h"
#include "JHLEDBackpack.cpp"

#define DEFAULT_CAMERA -1	// -1 for onboard camera, or change to index of /dev/video V4L2 camera (>=0)	
		

bool signal_recieved = false;

int getkey()

I’ve tried putting it in various different folders but this is the only way i got it to compile so far, I’ve got the SDA and SCL hooked up to oscilloscope and … nothing !!!

I’ve whittled the problem down to this:

#include <unistd.h>			//Needed for I2C port
#include <fcntl.h>			//Needed for I2C port
#include <sys/ioctl.h>			//Needed for I2C port
#include <linux/i2c-dev.h>		//Needed for I2C port

        int file_i2c;
	int length;
	unsigned char buffer[60] = {0};

	
	//----- OPEN THE I2C BUS -----
	char *filename = (char*)"/dev/i2c-1";
	if ((file_i2c = open(filename, O_RDWR)) < 0)
	{
		//ERROR HANDLING: you can check errno to see what went wrong
		printf("Failed to open the i2c bus");
		return;
	}

It compiles ok and “/dev/i2c-1” is correct, but … I can’t open the i2c bus.
Documentation ( i2c / dev-interface https://kernel.googlesource.com/pub/scm/linux/kernel/git/ralf/linux/+/linux-2.5.54/Documentation/i2c/dev-interface) says:

IMPORTANT: because of the use of inline functions, you have to use
‘-O’ or some variation when you compile your program!

The above code works when it’s compiled on it’s own with -O but not when compiled with detectnet-camera.cpp.

What does ‘-O’ mean and how do i get the above code working within detectnet-camera.cpp ???
Thanks !

Have you checked the actual error number that is being generated? Are you running your program with sudo? For using I2C, you will need to run the program with ‘sudo’ to access I2C unless you have set up some UDEV rules.

Thanks for reply, Jim. It’s error = 9, but I don’t know what this means! I’ll check if I’m using sudo or not know …

Sudo works ! Thanks Jim ! Now to try and write the bounding box details over I2C …… Should be fun !