# How to use Amb82-mini as USB camera with NN

**URL:** <https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259>\
**Category:** Multimedia\
**Tags:** rtl8735b, evb-amb82\
**Created:** [July 21, 2025, 8:49am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259 "2025-07-21T08:49:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jia\_Yan\_Lu](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/jia_yan_lu/32/2733_2.png) [@Jia\_Yan\_Lu](https://forum.amebaiot.com/u/Jia_Yan_Lu)\
**Post date:** [July 21, 2025, 8:49am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/1 "2025-07-21T08:49:17Z")

</div>

I want to use Amb82-mini as USB camera with NN, the code below combines sample code of UVC\_device and Object detection  
The web cam works fine, but the NN seems not working,  
the logs show below

```auto

#include "StreamIO.h"
#include "VideoStream.h"
#include "RTSP.h"
#include "NNObjectDetection.h"
#include "VideoStreamOverlay.h"
#include "ObjectClassList.h"
#include "UVCD.h"

#define STREAM_CHANNEL 0
#define CHANNELNN 3

// Lower resolution for NN processing
#define NNWIDTH 576
#define NNHEIGHT 320

VideoSetting config(USB_UVCD_STREAM_PRESET);
VideoSetting configNN(NNWIDTH, NNHEIGHT, 10, VIDEO_RGB, 0);
VideoSetting stream_config(USB_UVCD_STREAM_PRESET);
Video camera_uvcd;
NNObjectDetection ObjDet;
StreamIO videoStreamer(1, 1);
StreamIO videoStreamerNN(1, 1);

UVCD usb_uvcd;
unsigned long last_infer_time = 0;
const unsigned long infer_interval = 10000; // 每 1000ms 推論一次

void setup()
{
    Serial.begin(115200);

    // Configure camera video channel with video format information
    config.setBitrate(2 * 1024 * 1024);
    Camera.configVideoChannel(STREAM_CHANNEL, config);
    Camera.configVideoChannel(CHANNELNN, configNN);
    Camera.videoInit();

    // Configure usb_uvcd with identical video format information
    usb_uvcd.configVideo(config);

    // Configure object detection with corresponding video format information
    // Select Neural Network(NN) task and models
    ObjDet.configVideo(configNN);
    ObjDet.modelSelect(OBJECT_DETECTION, DEFAULT_YOLOV4TINY, NA_MODEL, NA_MODEL);
    ObjDet.begin();

    // Configure StreamIO object to stream data from camera video channel to usb_uvcd
    videoStreamer.registerInput(Camera.getStream(STREAM_CHANNEL));
    videoStreamer.registerOutput(usb_uvcd);
    if (videoStreamer.begin() != 0) {
        Serial.println("StreamIO link start failed");
    }

    // Start data stream from video channel
    Camera.channelBegin(STREAM_CHANNEL);

    videoStreamerNN.registerInput(Camera.getStream(CHANNELNN));
    videoStreamerNN.setStackSize();
    videoStreamerNN.setTaskPriority();
    videoStreamerNN.registerOutput(ObjDet);
    if (videoStreamerNN.begin() != 0) {
        Serial.println("StreamIO link start failed");
    }
        // Start video channel for NN
    Camera.channelBegin(CHANNELNN);

    // Start OSD drawing on RTSP video channel
    OSD.configVideo(STREAM_CHANNEL, config);
    OSD.begin();
    // Start usb uvcd
    usb_uvcd.begin(Camera.getStream(STREAM_CHANNEL), videoStreamer.linker, STREAM_CHANNEL);
    //usb_uvcd.begin(Camera.getStream(CHANNELNN), videoStreamerNN.linker, CHANNELNN);
    

}

void loop()
{

    std::vector<ObjectDetectionResult> results = ObjDet.getResult();

    uint16_t im_h = config.height();
    uint16_t im_w = config.width(); 
    Serial.print("Detected objects");
    Serial.print(results.size(), DEC);
    Serial.print("\n\n");
    Serial.print("Total number of objects detected");
    Serial.print(ObjDet.getResultCount(), DEC);
    Serial.print("\n\n");

    OSD.createBitmap(STREAM_CHANNEL);

    if (ObjDet.getResultCount() > 0) {
        for (int i = 0; i < ObjDet.getResultCount(); i++) {
            int obj_type = results[i].type();
            if (itemList[obj_type].filter) { // check if item should be ignored

                ObjectDetectionResult item = results[i];
                // Result coordinates are floats ranging from 0.00 to 1.00
                // Multiply with RTSP resolution to get coordinates in pixels
                int xmin = (int)(item.xMin() * im_w);
                int xmax = (int)(item.xMax() * im_w);
                int ymin = (int)(item.yMin() * im_h);
                int ymax = (int)(item.yMax() * im_h);

                // Draw boundary box
                printf("Item %d %s:\t%d %d %d %d\n\r", i, itemList[obj_type].objectName, xmin, xmax, ymin, ymax);
                OSD.drawRect(STREAM_CHANNEL, xmin, ymin, xmax, ymax, 3, OSD_COLOR_WHITE);

                // Print identification text
                char text_str[20];
                snprintf(text_str, sizeof(text_str), "%s %d", itemList[obj_type].objectName, item.score());
                OSD.drawText(STREAM_CHANNEL, xmin, ymin - OSD.getTextHeight(STREAM_CHANNEL), text_str, OSD_COLOR_CYAN);
            }
        }
    }
    OSD.update(STREAM_CHANNEL);

    delay(500);
}

```

```auto

YOLOv4t tick[60]

YOLOv4t tick[64]

YOLOv4t tick[58]

YOLOv4t tick[60]

YOLOv4t tick[64]

YOLOv4t tick[58]

YOLOv4t tick[60]

YOLOv4t tick[64]

YOLOv4t tick[58]

>>> YOLOv4t FPS = 6.00

YOLOv4t tick[60]

YOLOv4t tick[64]

YOLOv4t tick[58]

YOLOv4t tick[59]

YOLOv4t tick[62]

YOLOv4t tick[57]

YOLOv4t tick[59]

YOLOv4t tick[61]

```

---

<div class="post-metadata">

**Author:** ![KaiFai\_Y](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/kaifai_y/32/2252_2.png) [@KaiFai\_Y](https://forum.amebaiot.com/u/KaiFai_Y)\
**Post date:** [July 22, 2025, 1:44am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/2 "2025-07-22T01:44:37Z")

</div>

hi @Jia_Yan_Lu , currently there is an example’s UVCDObjectDetectinLoop at Arduino, you may refer to the [guide](https://ameba-doc-arduino-sdk.readthedocs-hosted.com/en/latest/ameba_pro2/amb82-mini/Example_Guides/Neural%20Network/UVCD%20Object%20Detection.html) for more information. Thank you.

---

<div class="post-metadata">

**Author:** ![Jia\_Yan\_Lu](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/jia_yan_lu/32/2733_2.png) [@Jia\_Yan\_Lu](https://forum.amebaiot.com/u/Jia_Yan_Lu)\
**Post date:** [July 22, 2025, 3:44am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/3 "2025-07-22T03:44:05Z")

</div>

Thank you, solved!

---

<div class="post-metadata">

**Author:** ![Jia\_Yan\_Lu](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/jia_yan_lu/32/2733_2.png) [@Jia\_Yan\_Lu](https://forum.amebaiot.com/u/Jia_Yan_Lu)\
**Post date:** [August 5, 2025, 8:20am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/4 "2025-08-05T08:20:20Z")

</div>

@KaiFai_Y Hi, I wonder if it’s also possible to use Amb82-mini as USB camera with image classification?

---

<div class="post-metadata">

**Author:** ![KaiFai\_Y](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/kaifai_y/32/2252_2.png) [@KaiFai\_Y](https://forum.amebaiot.com/u/KaiFai_Y)\
**Post date:** [August 6, 2025, 1:17am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/5 "2025-08-06T01:17:58Z")

</div>

Hi @Jia_Yan_Lu , you may try on it. You may use the [obj detection](https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/UVCDObjectDetectionLoop/UVCDObjectDetectionLoop.ino) and [image classification](https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/RTSPImageClassification/RTSPImageClassification.ino) examples and modify by changing the classes from ObjDet to imgclass, modelSelect to select image classification model. Lastly, change the [ObjectClassList.h](https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/UVCDObjectDetectionLoop/ObjectClassList.h).to [ClassificationClassList.h](https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/RTSPImageClassification/ClassificationClassList.h). Thank you.

---

<div class="post-metadata">

**Author:** ![Jia\_Yan\_Lu](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/jia_yan_lu/32/2733_2.png) [@Jia\_Yan\_Lu](https://forum.amebaiot.com/u/Jia_Yan_Lu)\
**Post date:** [August 6, 2025, 5:14am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/6 "2025-08-06T05:14:28Z")

</div>

Hi, I have tried to merge [image classification](https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/RTSPImageClassification/RTSPImageClassification.ino) and [UVCD ObjectDetection Loop](https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/UVCDObjectDetectionLoop/UVCDObjectDetectionLoop.ino) follow your instruction.

here is my code

```auto
/*
 This example describes how to use USB UVCD api with OBJECT_DETECTION.
 In this example, the device is setup to function as a USB camera.
 Connect to PC and use the device as a USB camera.
 Perform objects prediction when the device is connect to PC and PotPlayer.

 Example guide: TBD

 NN Model Selection
 Select Neural Network(NN) task and models using modelSelect(nntask, objdetmodel, facedetmodel, facerecogmodel).
 Replace with NA_MODEL if they are not necessary for your selected NN Task.

 NN task
 =======
 OBJECT_DETECTION/ FACE_DETECTION/ FACE_RECOGNITION

 Models
 =======
 YOLOv3 model DEFAULT_YOLOV3TINY / CUSTOMIZED_YOLOV3TINY
 YOLOv4 model DEFAULT_YOLOV4TINY / CUSTOMIZED_YOLOV4TINY
 YOLOv7 model DEFAULT_YOLOV7TINY / CUSTOMIZED_YOLOV7TINY
 SCRFD model DEFAULT_SCRFD / CUSTOMIZED_SCRFD
 MobileFaceNet model DEFAULT_MOBILEFACENET/ CUSTOMIZED_MOBILEFACENET
 No model NA_MODEL
 */

#include "StreamIO.h"
#include "VideoStream.h"
#include "UVCD.h"
#include "NNImageClassification.h"
#include "VideoStreamOverlay.h"
#include "ClassificationClassList.h"

#define IMAGERGB 1

#define STREAM_CHANNEL 0
#define CHANNELNN 3

int reconnect = 0;
int disconnect = 0;

Video camera_uvcd;
//NNObjectDetection ObjDet;
NNImageClassification imgclass;
UVCD usb_uvcd;

// Lower resolution for NN processing
#define NNWIDTH 224
#define NNHEIGHT 224

StreamIO videoStreamer(1, 1); // 1 Input Video -> 1 Output USB_CAM
StreamIO videoStreamerNN(1, 1);
VideoSetting stream_config(USB_UVCD_STREAM_PRESET);
VideoSetting configNN(NNWIDTH, NNHEIGHT, 10, VIDEO_RGB, 0);
VideoSetting config(VIDEO_FHD, 30, VIDEO_H264, 0);
void setup()
{
    Serial.begin(115200);
    // Configure camera video channel with video format information
    camera_uvcd.configVideoChannel(STREAM_CHANNEL, stream_config);

    camera_uvcd.configVideoChannel(CHANNELNN, configNN);
    // Configure usb_uvcd with identical video format information
    usb_uvcd.configVideo(stream_config);
    camera_uvcd.videoInit();

    // Configure object detection with corresponding video format information
    // Select Neural Network(NN) task and models
    //ObjDet.configVideo(configNN);
    //ObjDet.modelSelect(OBJECT_DETECTION, DEFAULT_YOLOV4TINY, NA_MODEL, NA_MODEL);
    //ObjDet.begin();
    imgclass.configVideo(configNN);
    imgclass.configInputImageColor(IMAGERGB);
    imgclass.setResultCallback(ICPostProcess);
    imgclass.modelSelect(IMAGE_CLASSIFICATION, NA_MODEL, NA_MODEL, NA_MODEL, NA_MODEL, DEFAULT_IMGCLASS);
    imgclass.begin();

    // Configure StreamIO object to stream data from camera video channel to usb_uvcd
    videoStreamer.registerInput(camera_uvcd.getStream(STREAM_CHANNEL));
    videoStreamer.registerOutput(usb_uvcd);
    if (videoStreamer.begin() != 0) {
        Serial.println("StreamIO link start failed");
    }
    // Start data stream from video channel
    camera_uvcd.channelBegin(STREAM_CHANNEL);

    // Configure StreamIO object to stream data from RGB video channel to object detection
    videoStreamerNN.registerInput(camera_uvcd.getStream(CHANNELNN));
    videoStreamerNN.setStackSize();
    videoStreamerNN.setTaskPriority();
    videoStreamerNN.registerOutput(imgclass);
    if (videoStreamerNN.begin() != 0) {
        Serial.println("StreamIO link start failed");
    }

    // Start video channel for NN
    camera_uvcd.channelBegin(CHANNELNN);

    // Start usb uvcd for NN
    usb_uvcd.nnbegin(camera_uvcd.getStream(STREAM_CHANNEL), videoStreamer.linker, STREAM_CHANNEL, CHANNELNN, camera_uvcd.videostream_status(STREAM_CHANNEL));

    //OSD.configVideo(STREAM_CHANNEL, config);
    //OSD.begin();
}

void loop()
{

}

void disconnectNN()
{
    camera_uvcd.channelEnd(CHANNELNN); // Stop video channel from NN
    camera_uvcd.channelBegin(STREAM_CHANNEL); // Stop video channel from video channel
    reconnect = 1;
    disconnect = 1;
}

void reconnectNN()
{
    camera_uvcd.channelBegin(CHANNELNN); // Start video channel for NN
    camera_uvcd.channelBegin(STREAM_CHANNEL); // Start video channel for video channel
    reconnect = 0;
    disconnect = 0;
}
void ICPostProcess(void)
{
    if (!usb_uvcd.isUsbUvcConnected(camera_uvcd.videostream_status(STREAM_CHANNEL))) {
        Serial.println("USB UVC device disconnected");
        // Handle disconnection processes
        if (disconnect == 0) {
            disconnectNN();
        }
        return;
    } 
    else {
        // Handle reconnection or restart processes
        if (reconnect == 1) {
            reconnectNN();
        }  
        int class_id = imgclass.classID();
        if (imgclassItemList[class_id].filter) { // header file
            float prob = imgclass.score();
            printf("class %d, score: %f, name: %s\r\n", class_id, prob, imgclassItemList[class_id].imgclassName);
        }
    }

    delay(500);
    
}

```

and now the problem is the webcam works fine, but I did not get any output from image classification

below is the log from plug in and open/close PotPlayer

```auto

== Rtl8735b IoT Platform ==

[Normal mode]
BootFromNORFlash
[Start Boot ROM...]
=== Load PARTBL ===
=== Load Done ===
=== Load ISP_IQ ===
[fcs chk pass]
ISP_IQ @ 0x8461080, 0x2ff80, 0x0
mfcs_data version 0x00010001
fcs_data version 0x00010101
=== Process ISP_IQ ===
=== Load Done ===
=== Load BL ===
[Image Start Table @ 0x18200]
=== Load Done ===

== Boot Loader ==
Oct 24 2024:17:41:10
=== Load FCS Para ===
=== Load Done ===
[crc pass]
=== Load ISP_IQ Sensor ===
ISP_IQ @ 0x8461080, 0x2ff80
=== Process ISP_IQ ===
=== Load Done ===
=== Load FW1 ===
FW_ISP_IQ @ 0x8061080, 0x31f80
=== Process FW_ISP_IQ ===
DRAM_TYPE is DDR2 128MB.
ddr_freq = 533
VOE flash @ 0x8093080, 0x80f80
FCS KM_status 0x00002081 err 0x0000200a
                                       Wait KM fcs done 0 us
FCS TM_status 0x003f0000
                         store fcs data for application
                                                        It don't do the sensor initial process
RAM TM_STATUS 0x00bf1208 err 0x00001208
                                        read fcs_status 0x000000bf
                                                                   read fcs_status 0x000000bf
             === Process VOE IMG ===
[Image Start Table @ 0x20106200]
RAM Load @ 0x8114100->0x20106200, 0x6260
DDR Load @ 0x811b080->0x70100000, 0x6dcb0
=== FW Load Done ===

Boot Loader <==

== RAM Start ==
Build @ 17:32:16, Oct 24 2024

$8735b>OTG DRIVER VER: 0826
p_data.len= 2
uvc_hs_streaming_ep= 83
[OTG Err]ERROR:: ep_enable, bogus device state

                                              [video_voe_presetting] fps:30 w:1920 h:1080
fwin(1),enc_en(0),IQ_OFFSET = 0x17b60
 fwin(1),enc_en(0),SENSOR_OFFSET = 0x2fba0
sensor id 1 iq_data 17b60 sensor_data 2fba0
fwin(1),enc_en(0),IQ_OFFSET = 0x17b60
 fwin(1),enc_en(0),SENSOR_OFFSET = 0x2fba0
sensor id 1 iq_data 17b60 sensorset_alt interface 0 alt =0
set_alt interface 1 alt =0
_daset_alt interface 1 alt =0
ta 2fba0
NN IRQ default priority : 0, set to 9
VIPLite Drv version 1.12.0
Deploy Image Classification
set_alt interface 1 alt =0
input 0 dim 416 416 3 1, data format=2, quant_format=2, scale=0.003922, zero_point=0
ouput 0 dim 52 52 255 1, data format=2, scale=0.003919, zero_point=0
ouput 1 dim 26 26 255 1, data format=2, scale=0.003921, zero_point=0
ouput 2 dim 13 13 255 1, data format=2, scale=0.003922, zero_point=0
---------------------------------
input count 1, output count 3
input param 0
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003922, zero_point=0
        sizes 416 416 3 1 0 0
output param 0
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003919, zero_point=0
        sizes 52 52 255 1 0 0
output param 1
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003921, zero_point=0
        sizes 26 26 255 1 0 0
output param 2
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003922, zero_point=0
        sizes 13 13 255 1 0 0
---------------------------------
hal_voe_ready 0x0 0xbf1208
 read fcs_status 0x000000bf
[video_init] uvcd iq is null, use default.
[video_init] uvcd SNR is null, use default.
IQ:FW size (98342)
sensor:date 2024/9/12 version:RTL8735B_VOE_1.5.7.0
sensor:FW size (5412)
sensor timestamp: 2024/09/12
iq timestamp: 2023/05/15 14:48:54
voe_heap malloc 0x7020b080, size 19917824
ISP:1 ENC:1 H265:1 NN:1
hal_voe_ready 0x0 0xbf1208
voe :RTL8735B_VOE_1.5.8.0
sensor:RTL8735B_VOE_1.5.7.0
hal :RTL8735B_VOE_1.5.8.0
load time sensor:68us iq:1222us itcm:0us dtcm:0us ddr:0us ddr2:0us
Set H264 default HIGH profile
[video_pre_init_procedure] START
[VOE]ext_in = 0 sync = 0
[VOE][Ini set0]init dn 0 hdr 0 mirrorflip 0xf0
[VOE]g_init_fps: 30
[VOE]md init success
[VOE]algo ver 187ea48
[VOE]pack_v 0x0000 0x0002 cus_v 0 iq_id 0 dn 0 day 0 night 1 other 2 offset 224 length 16436 iq_size 32716
[VOE]Ver 0x0001000c Fast3A Cnt AE 1 AWB 1 period AE 5 AWB 1 delay 0 0
[VOE]hdr_mode 0 sensor driver num 1
[VOE]fps max 30.000000 min 2.000000
[VOE]exposure_step 29.629629
[VOE]change sensor mode => 1920x1080@30.000000fps - 'linear'
[VOE]min_fps 2.000000, max_fps 30.000000, exp_step 29.629629 dyn_fps 30.000000
[VOE]md ver 0x6d640100
[VOE]ae ver 0x61650200
[VOE]awb ver 0x77620100
[VOE]short exp mode is not implemented by this sensor.
                                                      [VOE]cur_hdr_mode = 0
[VOE]VOE MEM Size = 19451 Used= 3565 KB Free=15885 KB (16266688)
[VOE]stream 0 buffer 0: 0x70586700 size 3110400
[VOE]stream 0 buffer 1: 0x7087de00 size 3110400
[VOE]first_config_osd2_block_num[0]: 1
[VOE]osd2_block_num[0]: 24
[VOE]NV12 1920x1080 1/30
[VOE]dynamic set fps 0 -> 30 ok
[VOE]short exp mode is not implemented by this sensor.
                                                      [VOE]sensor power on
                                                                          [VOE]early mirror/flip 0 0
[VOE]zoom crop default setting
[VOE]cropw: 1920, croph: 1080
[VOE]scale down set_mcrop
[VOE]status == 1718
[VOE]buffer size == (0x70bb51a0) (1307776 259200) queue(239)
[VOE]Set rate control: bpsqp -1 qpRange I[0, 51] PB[0, 51] 1048576 bps pic 1 skip 0 hrd 0 cpbSize 1000000 bitrateWindow 80 intraQpDelta -5 fixedIntraQp 0
[VOE]Set PreP: input [VOE]frame_e1920x1080 :nd: sensor d offset idn't initia0x0 : formalize done !
ion 0cc 0 : scaling 0 : scaling format 0
[VOE]vcenc_set_ref_pic_set() NULL
                                 hal_voe_send2voe too long 182310 cmd 0x00000206 p1 0x00000000 p2 0x00000000
inputRateNumer[10] < outputRateNumer[30], Set inputRateNumer --> outputRateNumer
[VOE]ext_in = 0 sync = 0
[VOE]isp_device_probe had done
[VOE]isp_soc_start already done
                               [VOE]VOE MEM Size = 19451 Used= 17688 KB Free= 1762 KB (1804768)
[VOE]stream 4 buffer 0: 0x71351300 size 150528
[VOE]stream 4 buffer 1: 0x71376000 size 150528
[VOE]RGB3 224x224 1/10
[VOE]scale down set_mcrop
[VOE]status == 1718
[VOE]release s4 isp buffer 0
[VOE][WARN]useless release s4 slot0 status 0x00000000
[VOE]release s4 isp b[VOE][WARN]slot full : s0 int 0x00000004 buf 0x00000088 time 1293486 cnt 0 slot0 dn 1 rls 0 slot1 1 0 osd_t dn 1 0 rel 0 0
uffer 1
[VOE][WARN]useless release s4 slot1 status 0x00000000
Image Classification tick[76]
USB UVC device disconnected
[VOE]rts_rtsv_streamoff done <1118>
[VOE]rts_rtsv_request_bufs off done<1125>
[VOE]isp_close_stream success <1864>
[VOE]rt_osd2_deinit success <1882>
[VOE]isp_free_buffer success <2001>
hal_voe_send2voe too long 64996 cmd 0x00000207 p1 0x00000000 p2 0x00000004
Set H264 default HIGH profile
[VOE]ext_in = 0 sync = 0
[VOE]isp_device_probe had done
[VOE]isp_soc_start already done
                               [VOE]VOE MEM Size = 19451 Used= 17693 KB Free= 1757 KB (1799520)
[VOE] isp_locate_buffer malloc buffer failed
[VOE]isp_locate_buffer ch0 failed -1
VOE command 0x206 fail ret 0x1
VOE_OPEN_CMD command fail
hal_video_open fail
fun_suspend
fun_suspend
streaming request (req 81 cs 01)
probe
streaming request (req 01 cs 01)
setting commit control, length = 26
format ->7016ada4
interval[0] = 416666
format = 3 w = 1920 h = 1080 fps = 416666
streaming request (req 81 cs 01)
probe
streaming request (req 83 cs 01)
format ->7016ad8c ->7016ad8c
Type_ = 0finish output task
hal_video_output_task closed

format ->7016ad8c ->7016ad8c size 4147200
streaming request (req 82 cs 01)
format ->7016ad8c ->7016ad8c
Type_ = 0
format ->7016ad8c ->7016ad8c size 4147200
[VOE]sensor power off
                     [VOE]rts_rtsv_streamoff done <1118>
[VOE]rts_rtsv_request_bufs off done<1125>
[VOE]isp_close_stream success <1864>
[VOE]ch: 0 rt_osd2_deinit
[VOE]rt_osd2_deinit success <1882>
[VOE]Total HW Memory: 6528032
[VOE]Total SWHW Memory: 51456
[VOE]Total SW Memory: 16320
[VOE]Total Memory: 6595808
[VOE] isp_free_buffer no buffer need to be free
[VOE]isp_free_buffer failed -1
[VOE]voe close failed 0x10
hal_voe_send2voe too long 145992 cmd 0x00000207 p1 0x00000000 p2 0x00000000
VOE command 0x207 fail ret 0x1
VOE_CLOSE_CMD command fail ffffffff
hal_video_close fail
hal_voe_ready 0x0 0x1718
streaming request (req 01 cs 01)
setting commit control, length = 26
format ->7016ada4
interval[0] = 416666
format = 3 w = 1920 h = 1080 fps = 416666
streaming request (req 81 cs 01)
probe
streaming request (req 01 cs 02)
setting set_alt interface 1 alt =1
commit control, length = 26
setting commit control, length = 26
format ->7016ada4
interval[0] = 416666
format = 3 w = 1920 h = 1080 fps = 416666
hal_voe_ready 0x0 0x800000
 read fcs_status 0x00000080
[video_init] uvcd iq is null, use default.
[video_init] uvcd SNR is null, use default.
IQ:FW size (98342)
sensor:date 2024/9/12 version:RTL8735B_VOE_1.5.7.0
sensor:FW size (5412)
sensor timestamp: 2024/09/12
iq timestamp: 2023/05/15 14:48:54
RAM TM_STATUS 0x00801209 err 0x00001209
hal_voe_fcs_check_km_run_bypass 4617
voe:date 2024/10/18 version:RTL8735B_VOE_1.5.8.0
voe:FW size itcm(21792) dtcm(992) ddr(259992) ddr2(241794)
 read fcs_status 0x00000080
ISP:1 ENC:1 H265:1 NN:1
hal_voe_ready 0x1209 0x801209
voe :RTL8735B_VOE_1.5.8.0
sensor:RTL8735B_VOE_1.5.7.0
hal :RTL8735B_VOE_1.5.8.0
load time sensor:69us iq:1229us itcm:283us dtcm:15us ddr:3240us ddr2:4155us
Set H264 default HIGH profile
[video_pre_init_procedure] START
[VOE]ext_in = 0 sync = 0
[VOE][Ini set0]init dn 0 hdr 0 mirrorflip 0xf0
[VOE]g_init_fps: 30
[VOE]md init success
[VOE]algo ver 187ea48
[VOE]pack_v 0x0000 0x0002 cus_v 0 iq_id 0 dn 0 day 0 night 1 other 2 offset 224 length 16436 iq_size 32716
[VOE]Ver 0x0001000c Fast3A Cnt AE 1 AWB 1 period AE 5 AWB 1 delay 0 0
[VOE]hdr_mode 0 sensor driver num 1
[VOE]fps max 30.000000 min 2.000000
[VOE]exposure_step 29.629629
[VOE]change sensor mode => 1920x1080@30.000000fps - 'linear'
[VOE]min_fps 2.000000, max_fps 30.000000, exp_step 29.629629 dyn_fps 30.000000
[VOE]md ver 0x6d640100
[VOE]ae ver 0x61650200
[VOE]awb ver 0x77620100
[VOE]short exp mode is not implemented by this sensor.
                                                      [VOE]cur_hdr_mode = 0
[VOE]VOE MEM Size = 19451 Used= 3565 KB Free=15885 KB (16266688)
[VOE]stream 0 buffer 0: 0x70586700 size 3110400
[VOE]stream 0 buffer 1: 0x7087de00 size 3110400
[VOE]first_config_osd2_block_num[0]: 1
[VOE]osd2_block_num[0]: 24
[VOE][Ini set] ae gain 256 exp 10000
[VOE][Ini set] awb r_gain 361 b_gain 378
[VOE][Ini set] gray mode off
[VOE][Ini set] mirrorflip 0xf0
[VOE][Ini set] BRIGHTNESS 0
[VOE][Ini set] SATURATION 40
[VOE][Ini set] CONTRAST 50
[VOE][Ini set] FLICKER 1
[VOE][Ini set] WDR_MODE 2
[VOE][Ini set] WDR_LEVEL 80
[VOE]turn direct_i2c_mode 1
[VOE]NV12 1920x1080 1/30
[VOE]dynamic set fps 0 -> 30 ok
[VOE]short exp mode is not implemented by this sensor.
                                                      [VOE]sensor_start set fast ae cnt 2
[VOE]sensor power on
                    [VOE]early mirror/flip 0 0
[VOE]zoom crop default setting
[VOE]cropw: 1920, croph: 1080
[VOE]scale down set_mcrop
[VOE]status == 1718
[VOE]buffer size == (0x70bb4fa0) (1307776 259200) queue(279)
[VOE]Set rate control: bpsqp -1 qpRange I[0, 51] PB[0, 51] 1048576 bps pic 1 skip 0 hrd 0 cpbSize 1000000 bitrateWindow 72 intraQpDelta -5 fixedIntraQp 0
[VOE]Set PreP: input [VOE]frame_e1920x1080 :nd: sensor d offset idn't initia0x0 : formalize done !
ion 0cc 0 : scaling 0 : scaling format 0
[VOE]vcenc_set_ref_pic_set() NULL
                                 hal_voe_send2voe too long 214667 cmd 0x00000206 p1 0x00000000 p2 0x00000000
stream on
set_alt interface 1 alt =0
deinit iso
Free the buffer
stream RESET
fun_suspend

```

---

<div class="post-metadata">

**Author:** ![KaiFai\_Y](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/kaifai_y/32/2252_2.png) [@KaiFai\_Y](https://forum.amebaiot.com/u/KaiFai_Y)\
**Post date:** [August 7, 2025, 2:12am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/7 "2025-08-07T02:12:14Z")

</div>

Hi @Jia_Yan_Lu , i saw your call back function ICPostProcess added the if else for disconnect and and connect uvcd handler this should be at the void loop function. Thank you

---

<div class="post-metadata">

**Author:** ![Jia\_Yan\_Lu](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/jia_yan_lu/32/2733_2.png) [@Jia\_Yan\_Lu](https://forum.amebaiot.com/u/Jia_Yan_Lu)\
**Post date:** [August 7, 2025, 3:30am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/8 "2025-08-07T03:30:59Z")

</div>

Hi , thanks for the advice!

After follow the instruction, I encounter another problem

```auto
void loop()
{
    if (!usb_uvcd.isUsbUvcConnected(camera_uvcd.videostream_status(STREAM_CHANNEL))) {
        Serial.println("USB UVC device disconnected");
        // Handle disconnection processes
        if (disconnect == 0) {
            disconnectNN();
        }
        return;
    } 
    else {
        // Handle reconnection or restart processes
        if (reconnect == 1) {
            reconnectNN();
        }  
        
    }
    //delay(100);
}

void disconnectNN()
{
    camera_uvcd.channelEnd(CHANNELNN); // Stop video channel from NN
    camera_uvcd.channelBegin(STREAM_CHANNEL); // Stop video channel from video channel
    reconnect = 1;
    disconnect = 1;
}

void reconnectNN()
{
    camera_uvcd.channelBegin(CHANNELNN); // Start video channel for NN
    camera_uvcd.channelBegin(STREAM_CHANNEL); // Start video channel for video channel
    reconnect = 0;
    disconnect = 0;
}
void ICPostProcess(void)
{
    int class_id = imgclass.classID();
    if (imgclassItemList[class_id].filter) { // header file
        float prob = imgclass.score();
        printf("class %d, score: %f, name: %s\r\n", class_id, prob, imgclassItemList[class_id].imgclassName);
    }   
}

```

I keep getting “Bus Fault Status: BusFault Address Reg is invalid(Asyn. BusFault)"  
I’ve search other discussion of the problem, still don’t sure how to solve it

```auto
== Rtl8735b IoT Platform ==

[Normal mode]
BootFromNORFlash
[Start Boot ROM...]
=== Load PARTBL ===
=== Load Done ===
=== Load ISP_IQ ===
[fcs chk pass]
ISP_IQ @ 0x8461080, 0x2ff80, 0x0
mfcs_data version 0x00010001
fcs_data version 0x00010101
=== Process ISP_IQ ===
=== Load Done ===
=== Load BL ===
[Image Start Table @ 0x18200]
=== Load Done ===

== Boot Loader ==
Oct 24 2024:17:41:10
=== Load FCS Para ===
=== Load Done ===
[crc pass]
=== Load ISP_IQ Sensor ===
ISP_IQ @ 0x8461080, 0x2ff80
=== Process ISP_IQ ===
=== Load Done ===
=== Load FW1 ===
FW_ISP_IQ @ 0x8061080, 0x31f80
=== Process FW_ISP_IQ ===
DRAM_TYPE is DDR2 128MB.
ddr_freq = 533
VOE flash @ 0x8093080, 0x80f80
FCS KM_status 0x00002081 err 0x0000200a
                                       Wait KM fcs done 0 us
FCS TM_status 0x003f0000
                         store fcs data for application
                                                        It don't do the sensor initial process
RAM TM_STATUS 0x00bf1208 err 0x00001208
                                        read fcs_status 0x000000bf
                                                                   read fcs_status 0x000000bf
             === Process VOE IMG ===
[Image Start Table @ 0x20106200]
RAM Load @ 0x8114100->0x20106200, 0x6260
DDR Load @ 0x811b080->0x70100000, 0x6dcb0
=== FW Load Done ===

Boot Loader <==

== RAM Start ==
Build @ 17:32:16, Oct 24 2024

$8735b>OTG DRIVER VER: 0826
p_data.len= 2
uvc_hs_streaming_ep= 83
[OTG Err]ERROR:: ep_enable, bogus device state

                                              [video_voe_presetting] fps:30 w:1920 h:1080
fwin(1),enc_en(0),IQ_OFFSET = 0x17b60
 fwin(1),enc_en(0),SENSOR_OFFSET = 0x2fba0
sensor id 1 iq_data 17b60 sensor_data 2fba0
fwin(1),enc_en(0),IQ_OFFSET = 0x17b60
 fwin(1),enc_en(0),SENSOR_OFFSET = 0x2fba0
sensor id 1 iq_data 17b60set_alt interface 0 alt =0
set_alt interface 1 alt =0
set_alt interface 1 alt =0
 sensor_data 2fba0
NN IRQ default priority : 0, set to 9
set_alt interface 1 alt =0
VIPLite Drv version 1.12.0
Deploy Image Classification
input 0 dim 416 416 3 1, data format=2, quant_format=2, scale=0.003922, zero_point=0
ouput 0 dim 52 52 255 1, data format=2, scale=0.003919, zero_point=0
ouput 1 dim 26 26 255 1, data format=2, scale=0.003921, zero_point=0
ouput 2 dim 13 13 255 1, data format=2, scale=0.003922, zero_point=0
---------------------------------
input count 1, output count 3
input param 0
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003922, zero_point=0
        sizes 416 416 3 1 0 0
output param 0
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003919, zero_point=0
        sizes 52 52 255 1 0 0
output param 1
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003921, zero_point=0
        sizes 26 26 255 1 0 0
output param 2
        data_format 2
        memory_type 0
        num_of_dims 4
        quant_format 2
        quant_data , scale=0.003922, zero_point=0
        sizes 13 13 255 1 0 0
---------------------------------
hal_voe_ready 0x0 0xbf1208
 read fcs_status 0x000000bf
[video_init] uvcd iq is null, use default.
[video_init] uvcd SNR is null, use default.
IQ:FW size (98342)
sensor:date 2024/9/12 version:RTL8735B_VOE_1.5.7.0
sensor:FW size (5412)
sensor timestamp: 2024/09/12
iq timestamp: 2023/05/15 14:48:54
voe_heap malloc 0x7020b160, size 19917824
ISP:1 ENC:1 H265:1 NN:1
hal_voe_ready 0x0 0xbf1208
voe :RTL8735B_VOE_1.5.8.0
sensor:RTL8735B_VOE_1.5.7.0
hal :RTL8735B_VOE_1.5.8.0
load time sensor:67us iq:1222us itcm:0us dtcm:0us ddr:0us ddr2:0us
Set H264 default HIGH profile
[video_pre_init_procedure] START
[VOE]ext_in = 0 sync = 0
[VOE][Ini set0]init dn 0 hdr 0 mirrorflip 0xf0
[VOE]g_init_fps: 30
[VOE]md init success
[VOE]algo ver 187ea48
[VOE]pack_v 0x0000 0x0002 cus_v 0 iq_id 0 dn 0 day 0 night 1 other 2 offset 224 length 16436 iq_size 32716
[VOE]Ver 0x0001000c Fast3A Cnt AE 1 AWB 1 period AE 5 AWB 1 delay 0 0
[VOE]hdr_mode 0 sensor driver num 1
[VOE]fps max 30.000000 min 2.000000
[VOE]exposure_step 29.629629
[VOE]change sensor mode => 1920x1080@30.000000fps - 'linear'
[VOE]min_fps 2.000000, max_fps 30.000000, exp_step 29.629629 dyn_fps 30.000000
[VOE]md ver 0x6d640100
[VOE]ae ver 0x61650200
[VOE]awb ver 0x77620100
[VOE]short exp mode is not implemented by this sensor.
                                                      [VOE]cur_hdr_mode = 0
[VOE]VOE MEM Size = 19451 Used= 3565 KB Free=15885 KB (16266688)
[VOE]stream 0 buffer 0: 0x70586800 size 3110400
[VOE]stream 0 buffer 1: 0x7087df00 size 3110400
[VOE]first_config_osd2_block_num[0]: 1
[VOE]osd2_block_num[0]: 24
[VOE]NV12 1920x1080 1/30
[VOE]dynamic set fps 0 -> 30 ok
[VOE]short exp mode is not implemented by this sensor.
                                                      [VOE]sensor power on
                                                                          [VOE]early mirror/flip 0 0
[VOE]zoom crop default setting
[VOE]cropw: 1920, croph: 1080
[VOE]scale down set_mcrop
[VOE]status == 1718
[VOE]buffer size == (0x70bb5280) (1307776 259200) queue(239)
[VOE]Set rate control: bpsqp -1 qpRange I[0, 51] PB[0, 51] 1048576 bps pic 1 skip 0 hrd 0 cpbSize 1000000 bitrateWindow 80 intraQpDelta -5 fixedIntraQp 0
[VOE]Set PreP: input [VOE]frame_e1920x1080 :nd: sensor d offset idn't initia0x0 : formalize done !
ion 0cc 0 : scaling 0 : scaling format 0
[VOE]vcenc_set_ref_pic_set() NULL
                                 hal_voe_send2voe too long 181453 cmd 0x00000206 p1 0x00000000 p2 0x00000000
inputRateNumer[10] < outputRateNumer[30], Set inputRateNumer --> outputRateNumer
[VOE]ext_in = 0 sync = 0
[VOE]isp_device_probe had done
[VOE]isp_soc_start already done
                               [VOE]VOE MEM Size = 19451 Used= 17688 KB Free= 1762 KB (1804768)
[VOE]stream 4 buffer 0: 0x71351400 size 150528
[VOE]stream 4 buffer 1: 0x71376100 size 150528
[VOE]RGB3 224x224 1/10
[VOE]scale down set_mcrop
[VOE]status == 1718
[VOE]release s4 isp buffer 0
[VOE][WARN]useless release s4 slot0 status 0x00000000
[VOE]release s4 isp b[VOE][WARN]slot full : s0 int 0x00000004 buf 0x00000088 time 1287245 cnt 0 slot0 dn 1 rls 0 slot1 1 0 osd_t dn 1 0 rel 0 0
uffer 1
[VOE][WARN]useless release s4 slot1 status 0x00000000
Image Classification tick[76]
Image Classification tick[72]
class 2, score: 0.000000, name: metal
Image Classification tick[74]
class 51, score: 0.000000, name:
Bus Fault:
SCB Configurable Fault Status Reg = 0x00000400

Bus Fault Status:
BusFault Address Reg is invalid(Asyn. BusFault)
Imprecise data bus error:
a data bus error has occurred, but the return address in the stack frame is not related to the instruction that caused the error.

S-domain exception from Thread mode, Extended Stack frame on S-PSP
Registers Saved to stack

Stacked:
R0 = 0x71629cc4
R1 = 0x2c2a0006
R2 = 0xffffffde
R3 = 0x2c2a0007
R4 = 0x10095378
R5 = 0x201068d1
R6 = 0x00000000
R7 = 0x00000000
R8 = 0x00000000
R9 = 0x70151c7c
R10 = 0x00000000
R11 = 0x00000006
R12 = 0x0000001c
LR = 0x20106625
PC = 0x10094e1c
PSR = 0x01100000

Current:
LR = 0xffffffed
MSP = 0x20003fd8
PSP = 0x71629b70
xPSR = 0x00000005
CFSR = 0x00000400
HFSR = 0x00000000
DFSR = 0x00000000
MMFAR = 0x00000000
BFAR = 0x00000000
AFSR = 0x00000000
PriMask = 0x00000000
SVC priority: 0x00
PendSVC priority: 0xf0
Systick priority: 0xf0

MSP Data:
20003FD8: 70176C3C FFFFFFF9 20004000 000003E8
20003FE8: E000E000 70176C3C 07070707 70139D3D
20003FF8: 70139DA8 21000000 BFBFFBAE B5F5EF57
20004008: BE9D53D4 647E6F17 160F756A AFE42FB1
20004018: 7BCB2FE2 BF1EE6E8 C4D98FEE 4BD2347F
20004028: 422422E4 7EF4EA0B FCD7566B BBDD5FCF
20004038: 713CE5BE 7C392EB2 DBAA756C 1D10290D
20004048: 3F815B92 5F08AB04 AA0397F4 F7C252AB
20004058: 54848974 73814F75 61079C67 71371544
20004068: 75102EF5 00718427 4414DADD F6564A1C
20004078: 0119CC24 B80A838E 76FE7CC1 CBD3C8F6
20004088: 445AFC10 90B82266 C28CE59F E9931B0E
20004098: BDC408A0 7D8ECDB0 5D438E0F D6FD783F
200040A8: 6F08E791 B1454FE5 E2DD42A7 42B1F017
200040B8: AAFF62F6 66D5640E 7857A6EF D79D7F56
200040C8: EC98166C 6C43A263 A4ADDA7B 45DBE96F

PSP Data:
71629B70: 71629CC4 2C2A0006 FFFFFFDE 2C2A0007
71629B80: 0000001C 20106625 10094E1C 01100000
71629B90: 201401E8 00000034 50040400 00000010
71629BA0: 9999999B 10095378 201068D1 00000000
71629BB0: 00000000 00000000 20100320 100949A3
71629BC0: 00000020 201068DD 00000000 10095378
71629BD0: 201068D1 100952D1 701F9020 71629CC0
71629BE0: 851EB852 3FE051EB 00000000 00000000
71629BF0: 00000006 10095378 00000000 00000000
71629C00: 2C2A0006 00000000 851EB852 3FE051EB
71629C10: 00000000 00000000 00000000 00000000
71629C20: 00000000 00000000 00000000 00000000
71629C30: 00000000 00000000 00000000 00000000
71629C40: 00000000 00000000 00000000 00000000
71629C50: 00000000 00000000 00000000 00000000
71629C60: 00000000 00000000 30000000 3030302E

 == NS Dump ==
CFSR_NS = 0x00000000
HFSR_NS = 0x00000000
DFSR_NS = 0x00000000
MMFAR_NS = 0x00000000
BFAR_NS = 0x00000000
AFSR_NS = 0x00000000
MSP_NS = 0x00000000
PSP_NS = 0x00000000
NS HardFault Status Reg = 0x00000000
SCB Configurable Fault Status Reg = 0x00000000
No Back Trace!
[VOE]cmd 0x020b ch 0 notify_tm_message wait ack 10000000

```

---

<div class="post-metadata">

**Author:** ![KaiFai\_Y](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/kaifai_y/32/2252_2.png) [@KaiFai\_Y](https://forum.amebaiot.com/u/KaiFai_Y)\
**Post date:** [August 7, 2025, 5:52am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/9 "2025-08-07T05:52:00Z")

</div>

hi @Jia_Yan_Lu, now version 4.0.9 had released, you may update in Arduino ide.

Here’s the code:

```auto
#include "StreamIO.h"
#include "VideoStream.h"
#include "UVCD.h"
#include "NNImageClassification.h"
#include "VideoStreamOverlay.h"
#include "ClassificationClassList.h"

#define IMAGERGB 1

#define STREAM_CHANNEL 0
#define CHANNELNN 3

int reconnect = 0;
int disconnect = 0;

Video camera_uvcd;
//NNObjectDetection ObjDet;
NNImageClassification imgclass;
UVCD usb_uvcd;

// Lower resolution for NN processing
#define NNWIDTH 224
#define NNHEIGHT 224

StreamIO videoStreamer(1, 1); // 1 Input Video -> 1 Output USB_CAM
StreamIO videoStreamerNN(1, 1);
VideoSetting stream_config(USB_UVCD_STREAM_PRESET);
VideoSetting configNN(NNWIDTH, NNHEIGHT, 10, VIDEO_RGB, 0);
VideoSetting config(VIDEO_FHD, 30, VIDEO_H264, 0);
void setup()
{
    Serial.begin(115200);
    // Configure camera video channel with video format information
    camera_uvcd.configVideoChannel(STREAM_CHANNEL, stream_config);

    camera_uvcd.configVideoChannel(CHANNELNN, configNN);
    // Configure usb_uvcd with identical video format information
    usb_uvcd.configVideo(stream_config);
    camera_uvcd.videoInit();

    // Configure object detection with corresponding video format information
    // Select Neural Network(NN) task and models
    //ObjDet.configVideo(configNN);
    //ObjDet.modelSelect(OBJECT_DETECTION, DEFAULT_YOLOV4TINY, NA_MODEL, NA_MODEL);
    //ObjDet.begin();
    imgclass.configVideo(configNN);
    imgclass.configInputImageColor(IMAGERGB);
    imgclass.setResultCallback(ICPostProcess);
    imgclass.modelSelect(IMAGE_CLASSIFICATION, NA_MODEL, NA_MODEL, NA_MODEL, NA_MODEL, DEFAULT_IMGCLASS);
    imgclass.begin();

    // Configure StreamIO object to stream data from camera video channel to usb_uvcd
    videoStreamer.registerInput(camera_uvcd.getStream(STREAM_CHANNEL));
    videoStreamer.registerOutput(usb_uvcd);
    if (videoStreamer.begin() != 0) {
        Serial.println("StreamIO link start failed");
    }
    // Start data stream from video channel
    camera_uvcd.channelBegin(STREAM_CHANNEL);

    // Configure StreamIO object to stream data from RGB video channel to object detection
    videoStreamerNN.registerInput(camera_uvcd.getStream(CHANNELNN));
    videoStreamerNN.setStackSize();
    videoStreamerNN.setTaskPriority();
    videoStreamerNN.registerOutput(imgclass);
    if (videoStreamerNN.begin() != 0) {
        Serial.println("StreamIO link start failed");
    }

    // Start video channel for NN
    camera_uvcd.channelBegin(CHANNELNN);

    // Start usb uvcd for NN
    usb_uvcd.nnbegin(camera_uvcd.getStream(STREAM_CHANNEL), videoStreamer.linker, STREAM_CHANNEL, camera_uvcd.videostream_status(STREAM_CHANNEL));

    OSD.configVideo(STREAM_CHANNEL, config);
    OSD.begin();
}

void loop()
{
    if (!usb_uvcd.isUsbUvcConnected(camera_uvcd.videostream_status(STREAM_CHANNEL))) {
        Serial.println("USB UVC device disconnected");
        // Handle disconnection processes
        if (disconnect == 0) {
            disconnectNN();
        }
        return;
    } else {
        // Handle reconnection or restart processes
        if (reconnect == 1) {
            reconnectNN();
        }
        
    }
    
    // delay to wait for new results
    delay(100);
}

void disconnectNN()
{
    camera_uvcd.channelEnd(CHANNELNN); // Stop video channel from NN
    camera_uvcd.channelBegin(STREAM_CHANNEL); // Stop video channel from video channel
    reconnect = 1;
    disconnect = 1;
}

void reconnectNN()
{
    camera_uvcd.channelBegin(CHANNELNN); // Start video channel for NN
    camera_uvcd.channelBegin(STREAM_CHANNEL); // Start video channel for video channel
    reconnect = 0;
    disconnect = 0;
}

// User callback function
void ICPostProcess(void)
{
    int class_id = imgclass.classID();
    if (imgclassItemList[class_id].filter) { // header file
        float prob = imgclass.score();
        printf("class %d, score: %f, name: %s\r\n", class_id, prob, imgclassItemList[class_id].imgclassName);
    }
}

```

---

<div class="post-metadata">

**Author:** ![Jia\_Yan\_Lu](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/jia_yan_lu/32/2733_2.png) [@Jia\_Yan\_Lu](https://forum.amebaiot.com/u/Jia_Yan_Lu)\
**Post date:** [August 7, 2025, 8:48am UTC](https://forum.amebaiot.com/t/how-to-use-amb82-mini-as-usb-camera-with-nn/4259/10 "2025-08-07T08:48:27Z")

</div>

Hi, thank you so much, solved 😃
