Luckfox pico Max Face Recognition

  • rajadey150@gmail.com wrote: 2024-03-20 16:16 Sir,please a sample program for facial recognition by RV1106 using RKNN lib and SSC3 camera,if there is already a sample code provide the link and how to compile it





    Hi,

    For facial recognition, it's generally necessary to have a display medium to observe the results. Below are two methods provided:

    Using the Waveshare Pico 1.3inch LCD or similar products to observe experimental results.
    Source code link:
    https://github.com/luckfox-eng29/luckfo ... fox_yolov5
    https://drive.google.com/file/d/1H2IiPO ... drive_link
    Relevant tutorial documentation:
    https://wiki.luckfox.com/Luckfox-Pico/RKNN-example

    Using RTSP streaming to observe experimental results on a PC.
    Source code link:
    https://github.com/luckfox-eng29/luckfo ... retinaface
    https://github.com/luckfox-eng29/luckfo ... naface_osd
    Relevant tutorial documentation:
    https://wiki.luckfox.com/Luckfox-Pico/RKMPI-example

    The corresponding documents and source code (Readme.md) specify the compilation and execution methods. If you encounter any problems, feel free to raise them, and I will do my best to help you resolve them.
  • Sir i have 3.5 restouch display i want interface with Luckfox Pico Max,so i will do this step


    Define the pin numbers in DEV_Config.h

    #define LCD_DC_PIN (34)
    #define LCD_CS_PIN (48) //Define LCD chip select pin number
    #define LCD_RST_PIN (57)
    #define LCD_BL_PIN (4)
    #define TP_CS_PIN (102)
    #define TP_IRQ_PIN (103)
    #define SD_CS_PIN (97)

    ....................


    uint8_t LCD_Read_Id(void)
    {
    uint8_t reg = 0xDC;
    uint8_t tx_val = 0x00;
    uint8_t rx_val;

    DEV_Digital_Write(LCD_CS_PIN, 0); // Initiate communication, pull down LCD_CS_PIN
    DEV_Digital_Write(LCD_DC_PIN, 0); // Pull down LCD_DC_PIN to indicate command transmission
    DEV_HARDWARE_SPI_TransferByte(reg); // Send command to LCD
    rx_val = DEV_HARDWARE_SPI_TransferByte(tx_val); // Send command to LCD and receive the return value
    DEV_Digital_Write(LCD_CS_PIN, 1); // End communication, pull up LCD_CS_PIN

    return rx_val; // Return the data read
    }
    i mean do we require change it manually or we have write our own code
    please help in tutorial very confusing
  • rajadey150@gmail.com wrote: 2024-03-21 6:50 Sir i have 3.5 restouch display i want interface with Luckfox Pico Max,so i will do this step
    i mean do we require change it manually or we have write our own code
    please help in tutorial very confusing



    The example on the Wiki https://wiki.luckfox.com/Luckfox-Pico/RKNN-example/ is implemented using the framebuffer.
    1.The software part of SPI communication with the screen is implemented by the kernel, utilizing mmap to map the screen display to a segment of memory. When data is written to this memory segment, the kernel automatically communicates with the screen via SPI to display the data.
    2.The hardware pin configuration is also done in the device tree.

    Theoretically, using SPI for read/write operations is possible, but it may result in significant efficiency losses, potentially leading to a lower display frame rate. Therefore, it is recommended to configure it as a framebuffer device.


    If you intend to use the LCD as an SPI device, you need to make the following modifications:
    1.Ensure that the screen can be driven correctly, referring to the tutorial https://wiki.luckfox.com/Luckfox-Pico/L ... Touch-LCD/
    2.open /cpp/main.cc in https://github.com/luckfox-eng29/luckfo ... ce_facenet
    3.Remove the parts related to the framebuffer:

    Code: Select all

        // Delete framebuffer Init
        /*
        int fb = open("/dev/fb0", O_RDWR);
        if(fb == -1)
        {
            close(fb);
            return -1;
        }
        size_t    screensize = FB_HIGHT * FB_WEIGHT * 2;
        uint16_t* framebuffer = (uint16_t*)mmap(NULL, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0);
        cv::Mat   rgb565Image(240, 240, CV_16UC1);
        */
        
        //Delete img show
        /*
        cv::resize(bgr, bgr, cv::Size(240,240), 0, 0, cv::INTER_LINEAR);
            for (int i = 0; i < bgr.rows; ++i) {
                for (int j = 0; j < bgr.cols; ++j) {
                    uint16_t b = (bgr.at<cv::Vec3b>(i, j)[0] >> 3);
                    uint16_t g = (bgr.at<cv::Vec3b>(i, j)[1] >> 2) << 5;
                    uint16_t r = (bgr.at<cv::Vec3b>(i, j)[2] >> 3) << 11;
    
                    rgb565Image.at<uint16_t>(i, j) = r | g | b;
                    framebuffer[i * FB_HIGHT + j] = rgb565Image.at<uint16_t>(i, j);
                }
          }
         */
    
    4.Replace the deleted parts with LCD screen initialization and image writing operations:

    Code: Select all

        //LCD Init
        if(DEV_ModuleInit() != 0){
            DEV_ModuleExit();
            exit(0);
        }
        SD_Init();
        LCD_SCAN_DIR  lcd_scan_dir = SCAN_DIR_DFT; 
        LCD_Init(lcd_scan_dir,800);
        Paint_CreatImage();
        
        //Show Image(This needs to be self-implemented)
        
    
    Note: Due to the difference in resolution between the 3.5-inch res-touch display and the Pico-LCD-1.3 used in the example, you need to resize the image to fit using Opencv-mobile for final image display.

    if you want to use the screen as a Framebuffer device, you need to make the following modifications:
    1.Modify the resolution:

    Code: Select all

        int width    = xxx;
        int height   = xxx;
    
    2.Modify the resolution after image scaling:

    Code: Select all

            cv::resize(bgr, bgr, cv::Size(xxx,xxx), 0, 0, cv::INTER_LINEAR);
    
    Note:Due to the model's structure, the input and output images used in the example are square, and no letterbox operation has been done. If you need to input rectangular images, you need to add a letterbox algorithm to ensure the correct flow of the model.


    I hope this information is helpful to you. If you encounter any difficulties during the implementation process, feel free to ask for assistance.
  • Respected Sir,

    I have gone through the tutorial
    1.Ensure that the screen can be driven correctly, referring to the tutorial https://wiki.luckfox.com/Luckfox-Pico/L ... Touch-LCD/;
    it is very confusing if you could provide right sdk or image file for LCD restouch 3.5 then it ok,
    i have installed provided image file but it is not working
    Please help to interface Luckfox Pico max with 3.5 ResTouch LCD
  • rajadey150@gmail.com wrote: 2024-03-21 8:26 Respected Sir,

    I have gone through the tutorial
    1.Ensure that the screen can be driven correctly, referring to the tutorial https://wiki.luckfox.com/Luckfox-Pico/L ... Touch-LCD/;
    it is very confusing if you could provide right sdk or image file for LCD restouch 3.5 then it ok,
    i have installed provided image file but it is not working
    Please help to interface Luckfox Pico max with 3.5 ResTouch LCD
    I have gone through the tests, unfortunately, I haven't encountered the issues you faced. Please check if the image is burned correctly, if the program is compiled correctly (there are differences between Plus and Pro/Max), and if the 3.5 ResTouch LCD can work properly (the lowest-cost way to test is using Raspberry Pico).

    If conditions permit, you can start a new topic to further describe the issues you encountered with the 3.5 ResTouch LCD. With the current information, I cannot determine at which stage the problem occurred.
  • Please send a tutorial video including changes in the c code and also provide a soft copy where it is changing for 3.5 lcd restive touch lcd
  • Sir please provide a sample code for camera capture image to 3.5 lcd for face detection
  • //LCD Init
    if(DEV_ModuleInit() != 0){
    DEV_ModuleExit();
    exit(0);
    }
    SD_Init();
    LCD_SCAN_DIR lcd_scan_dir = SCAN_DIR_DFT;
    LCD_Init(lcd_scan_dir,800);
    Paint_CreatImage();

    //Show Image(This needs to be self-implemented)
    i have tried this code but the library file is missing please give a proper library file structure for 3.5 LCD to excute this code in retina_face it will higly helpful
  • rajadey150@gmail.com wrote: 2024-03-22 6:24 //LCD Init
    if(DEV_ModuleInit() != 0){
    DEV_ModuleExit();
    exit(0);
    }
    SD_Init();
    LCD_SCAN_DIR lcd_scan_dir = SCAN_DIR_DFT;
    LCD_Init(lcd_scan_dir,800);
    Paint_CreatImage();

    //Show Image(This needs to be self-implemented)
    i have tried this code but the library file is missing please give a proper library file structure for 3.5 LCD to excute this code in retina_face it will higly helpful
    Thank you for your efforts. Due to the focus on utilizing RKNN during development, compatibility with screens was not a priority, and only the Framebuffer environment was tested. Currently, I am working on writing a demo that directly communicates with an LCD via SPI to display face recognition results. Once completed, I will upload it to GitHub and notify you immediately.