Skip to content

Commit 1457f15

Browse files
authored
Merge branch 'master' into docker-sysroot
2 parents c84c6f8 + 2efcd61 commit 1457f15

File tree

7 files changed

+27
-11
lines changed

7 files changed

+27
-11
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
bind_mount_repository: true
2222
commands: |
2323
apt-get update
24-
apt-get install -y libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev openjdk-17-jdk
24+
apt-get install -y libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk
2525
cmake -B build-pi -DCMAKE_BUILD_TYPE=Release
2626
cmake --build build-pi -- -j
2727

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 3.15)
2+
23
project(libcamera_meme)
34

45
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

camera_grabber.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ CameraGrabber::CameraGrabber(std::shared_ptr<libcamera::Camera> camera,
4545

4646
printf("Rotation = %i\n", rotation);
4747
if (rotation == 180) {
48-
using namespace libcamera;
49-
config->transform = Transform::HFlip * Transform::VFlip * libcamera::Transform::Identity;
48+
config->orientation = libcamera::Orientation::Rotate180;
5049
} else {
51-
config->transform = libcamera::Transform::Identity;
50+
config->orientation = libcamera::Orientation::Rotate0;
5251
}
5352

5453
if (config->validate() == libcamera::CameraConfiguration::Invalid) {

camera_model.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CameraModel stringToModel(const std::string& model) {
66
const char* famname = model.c_str();
77
if (!strcmp(famname, "ov5647")) return OV5647;
88
else if (!strcmp(famname, "imx219")) return IMX219;
9+
else if (!strcmp(famname, "imx708")) return IMX708;
910
else if (!strcmp(famname, "imx477")) return IMX477;
1011
else if (!strcmp(famname, "ov9281")) return OV9281;
1112
else if (!strcmp(famname, "ov7251")) return OV7251;

camera_model.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum CameraModel {
66
Disconnected = 0,
77
OV5647, // Picam v1
88
IMX219, // Picam v2
9+
IMX708, // Picam v3
910
IMX477, // Picam HQ
1011
OV9281,
1112
OV7251,

camera_runner.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ using latch = Latch;
1919
#include <libcamera/property_ids.h>
2020
#include <libcamera/control_ids.h>
2121

22+
#include <sys/ioctl.h>
23+
#include <linux/dma-buf.h>
24+
2225
using namespace std::chrono;
2326
using namespace std::chrono_literals;
2427

@@ -84,11 +87,6 @@ void CameraRunner::start() {
8487
.at(grabber.streamConfiguration().stream())
8588
->planes();
8689

87-
for (int i = 0; i < 3; i++) {
88-
// std::cout << "Plane " << (i + 1) << " has fd " << planes[i].fd.get() << " with offset " << planes[i].offset << std::endl;
89-
// std::cout << "Plane " << (i + 1) << " has fd " << planes[i].fd.get() << " with offset " << planes[i].offset << " and pitch " << static_cast<EGLint>(stride / 2) << std::endl;
90-
}
91-
9290
std::array<GlHsvThresholder::DmaBufPlaneData, 3> yuv_data{{
9391
{planes[0].fd.get(), static_cast<EGLint>(planes[0].offset),
9492
static_cast<EGLint>(stride)},
@@ -107,7 +105,6 @@ void CameraRunner::start() {
107105
rangeFromColorspace(colorspace),
108106
type);
109107

110-
111108
if (out != 0) {
112109
/*
113110
From libcamera docs:
@@ -177,6 +174,15 @@ void CameraRunner::start() {
177174
auto input_ptr = mmaped.at(data.fd);
178175
int bound = m_width * m_height;
179176

177+
178+
{
179+
struct dma_buf_sync dma_sync {};
180+
dma_sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_RW;
181+
int ret = ::ioctl(data.fd, DMA_BUF_IOCTL_SYNC, &dma_sync);
182+
if (ret)
183+
throw std::runtime_error("failed to start DMA buf sync");
184+
}
185+
180186
if (m_copyInput) {
181187
for (int i = 0; i < bound; i++) {
182188
std::memcpy(color_out_buf + i * 3, input_ptr + i * 4, 3);
@@ -188,6 +194,14 @@ void CameraRunner::start() {
188194
processed_out_buf[i] = input_ptr[i * 4 + 3];
189195
}
190196
}
197+
198+
{
199+
struct dma_buf_sync dma_sync {};
200+
dma_sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_RW;
201+
int ret = ::ioctl(data.fd, DMA_BUF_IOCTL_SYNC, &dma_sync);
202+
if (ret)
203+
throw std::runtime_error("failed to start DMA buf sync");
204+
}
191205

192206
m_thresholder.returnBuffer(data.fd);
193207
outgoing.set(std::move(mat_pair));

libcamera_jni.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Java_org_photonvision_raspi_LibCameraJNI_createCamera(JNIEnv *env, jclass,
6262
JNIEXPORT jint Java_org_photonvision_raspi_LibCameraJNI_getSensorModelRaw(
6363
JNIEnv *env, jclass clazz) {
6464

65-
bool runner_exists = runner > 0;
65+
bool runner_exists = runner != 0;
6666
if (!runner_exists) {
6767
Java_org_photonvision_raspi_LibCameraJNI_createCamera(env, clazz,
6868
320, 240, 30);

0 commit comments

Comments
 (0)