Issue in Installing pre-compiled driver for pivariety camera B0323 imx298

Is libcamera-apps applicable for all other native camera

Yes, it can be used with ov5647, imx219, imx477, you can find the introduction in the Raspberry Pi documentation:

Thank you for your support .

Dear Wong

I have tried libcamera-apps to write in c++ code but I couldn’t understand it . Is there any other sample code or derived code for libcamera to access pivariety camera directly . please kindly give support

Unfortunately, there is currently no such example.
Can you tell me what kind of example do you want?
Maybe we can write an example (of course it will take some time)

Thank Wong
I just need to access camera via libcamera (open,start,grabbing image,stop,close camera and to set camera properties ),then need to convert grabbed image into cv::mat .that’s all my requirement in libcamera .please give support if it is possible.

Ok, it looks like we can write such an example, but I can’t guarantee you when it will be completed.

Thanks Wong,I am also try to achieve required function, please Notify me if sample code is completed,

Sir, I have tried libcamera-apps with my application by successfully including depending library and libcamera_app.hpp and other .hpp files from core folder in libcamera-apps. Using LibcameraApp by declaring variable app to opencamera() its work fine,when I execute startcamera() method it leads to segmentation fault. I have tried to resolve it but didn’t got any solution . 1st is that Right to include and using of libcamera_app.hpp file at folder core in my application. please refer following code lines from .cpp file to open and start camera via libcamera_app.

#include <libcamera/camera.h>

#include <core/libcamera_app.hpp>

#include <core/completed_request.hpp>

#include <core/frame_info.hpp>

#include <core/libcamera_encoder.hpp>

#include <core/metadata.hpp>

#include <core/options.hpp>

#include <core/post_processor.hpp>

#include <core/still_options.hpp>

#include <core/version.hpp>

#include <core/video_options.hpp>


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
        captureImage();
}
void MainWindow::captureImage()

{
try
        {
             LibcameraApp  app;
              app.OpenCamera();
             if (options->immediate)
                  app.ConfigureStill(still_flags);
             else
                  app.ConfigureViewfinder();
           app.setupCapture();

          app.StartCamera(); //here segmentation fault is occured
       for (unsigned int count = 0; ; count++)
        {
            LibcameraApp::Msg msg = app.Wait();
            if (msg.type == LibcameraApp::MsgType::Quit)
                return ;
            else if (msg.type != LibcameraApp::MsgType::RequestComplete)
                throw std::runtime_error("unrecognised message!");

            auto now = std::chrono::high_resolution_clock::now();
            int key = get_key_or_signal(options, p);
           if (key == 'x' || key == 'X')
                return ;

            // In viewfinder mode, simply run until the timeout. When that happens, switch to
            // capture mode if an output was requested.
            if (app.ViewfinderStream())
            {
                if (options->verbose)
                    std::cerr << "Viewfinder frame " << count << std::endl;

                bool timed_out = options->timeout && now - start_time > std::chrono::milliseconds(options->timeout);
                bool keypressed = key == '\n';
                bool timelapse_timed_out = options->timelapse &&
                                           now - timelapse_time > std::chrono::milliseconds(options->timelapse);

                if (timed_out || keypressed || timelapse_timed_out)
                {
                     Trigger a still capture unless:
                    if (!output || // we have no output file
                        (timed_out && options->timelapse) || // timed out in timelapse mode
                        (!keypressed && keypress)) // no key was pressed (in keypress mode)
                        return ;
                    else
                    {
                        timelapse_time = std::chrono::high_resolution_clock::now();
                        app.StopCamera();
                        app.Teardown();
                        app.ConfigureStill(still_flags);
                        app.StartCamera();
                    }
                }
                else
                {
                          CompletedRequestPtr &completed_request = std::get<CompletedRequestPtr>(msg.payload);
                   app.ShowPreview(completed_request, app.ViewfinderStream());
                }
            }
           else if (app.StillStream())
            {
                app.StopCamera();
             }
        }
      }
                catch (std::exception const &e)
                {
                    std::cerr << "ERROR: *** " << e.what() << " ***" << std::endl;
                    return ;
                }
}

if I am wrong ,please give me correct way to access camera and to overcome this issue

If you are using libcamera_app, I think you need to initialize options:

LibcameraApp app;
Options *options = app.GetOptions();
options->Parse(0, NULL); //init options.
event_loop(app);

sir , as per your suggestion I have include the following line in my testing code .

Options *options = app.GetOptions();
options->Parse(0, NULL); //init options.

while execute init options it emits an abort singal to close application

sir ,if I tested the libcamera_still.cpp in qt5 it also gives same error as mentioned above

Well, you can wait a few days, and we plan to start writing a simple example next week.

Maybe you can refer to libcamera-hello, which is relatively simple.
This is the code I used for testing:

/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
 *
 * libcamera_hello.cpp - libcamera "hello world" app.
 */

#include <chrono>

#include "core/libcamera_app.hpp"
#include "core/options.hpp"

using namespace std::placeholders;

// The main event loop for the application.

static void event_loop(LibcameraApp &app)
{
	Options const *options = app.GetOptions();

	app.OpenCamera();
	app.ConfigureViewfinder();
	app.StartCamera();

	auto start_time = std::chrono::high_resolution_clock::now();

	for (unsigned int count = 0; ; count++)
	{
		LibcameraApp::Msg msg = app.Wait();
		if (msg.type == LibcameraApp::MsgType::Quit)
			return;
		else if (msg.type != LibcameraApp::MsgType::RequestComplete)
			throw std::runtime_error("unrecognised message!");

		if (options->verbose)
			std::cerr << "Viewfinder frame " << count << std::endl;
		auto now = std::chrono::high_resolution_clock::now();
		if (options->timeout && now - start_time > std::chrono::milliseconds(options->timeout))
			return;

		CompletedRequestPtr &completed_request = std::get<CompletedRequestPtr>(msg.payload);
		app.ShowPreview(completed_request, app.ViewfinderStream());
	}
}

int main(int argc, char *argv[])
{
	try
	{
		LibcameraApp app;
		Options *options = app.GetOptions();
		options->Parse(0, NULL);
		event_loop(app);
	}
	catch (std::exception const &e)
	{
		std::cerr << "ERROR: *** " << e.what() << " ***" << std::endl;
		return -1;
	}
	return 0;
}


sir I had received following error message in qt5
/home/pi/build-libcam-Desktop-Debug/../libcam/main.cpp:36: error: undefined reference to LibcameraApp::ShowPreview(std::shared_ptr&, libcamera::Stream*)’`

while building given simple test code

Hi @Balaji

We wrote an example based on libcamera-apps, you can refer to it.

libcamera-opencv

Thank Yang .
while execute Cmakelist.txt ,it end up with an error as follow

root@raspberrypi:/home/pi# cd libcamera-opencv/
root@raspberrypi:/home/pi/libcamera-opencv# mkdir build
root@raspberrypi:/home/pi/libcamera-opencv# cd build/
root@raspberrypi:/home/pi/libcamera-opencv/build# cmake ..
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No previous build - default to Release build
-- Platform: armhf
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'libcamera'
--   Found libcamera, version 1.0
-- libcamera library found:
--     version: 1.0
--     libraries: /usr/local/lib/arm-linux-gnueabihf/libcamera.so;/usr/local/lib/arm-linux-gnueabihf/libcamera-base.so
--     include path: /usr/local/include/libcamera
-- Found Boost: /usr/lib/arm-linux-gnueabihf/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: program_options 
CMake Error at apps/CMakeLists.txt:3 (find_package):
  By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenCV", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/pi/libcamera-opencv/build/CMakeFiles/CMakeOutput.log".
root@raspberrypi:/home/pi/libcamera-opencv/build# 

but I have installed open-cv in path /home/pi/installation/OpenCV.
if I need to edit CMakeList.txt to specify Opencv Path ,where I need to do

I have changed CMakeList.txt file to specify Opencv Path and it successfully installed .

Dear @Wong Thank for your support.

I have successfully integrated libcamera-apps opencv with my application and started to grab image continuously in cv::Mat but grab image with button click it grabs buffer image .
how to reduce buffer size of an image garbing in libcamera-app opencv .

You can try to modify this:
libcamera_app.cpp:
image

By the way, the current program is just a simple modification on libcamera_app, and there are many redundant things we did not delete. We plan to make a simpler and clearer example, but it will take some time.