Skip to content

Commit ae836e6

Browse files
committed
update: CameraCaptureを実機で動くように変更
1 parent d2a24d5 commit ae836e6

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

Makefile.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mkfile_path := $(dir $(lastword $(MAKEFILE_LIST)))
55

66
# Shellスクリプトで、moduleディレクトリ中のソースコード名をオブジェクトファイル名に変換している
77
SRCS := $(shell find ${mkfile_path}modules -name '*.cpp')
8+
SRCS += $(shell find ${mkfile_path}usb_camera -name '*.cpp')
89
OBJS := $(notdir $(SRCS:.cpp=.o))
910
APPL_CXXOBJS += $(OBJS)
1011

@@ -13,9 +14,11 @@ SRCLANG := c++
1314
APPL_LIBS += -lm
1415

1516
APPL_DIRS += $(mkfile_path)modules
17+
APPL_DIRS += $(mkfile_path)usb_camera
1618

1719
INCLUDES += \
1820
-I$(mkfile_path)modules\
21+
-I$(mkfile_path)usb_camera\
1922
-I/usr/include/opencv4
2023

2124
APPL_LIBS += $(shell pkg-config --libs opencv4)

tests/CameraCaptureTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
*/
66

77
#include <gtest/gtest.h>
8-
#include "../usb_camera/CameraCapure.h"
8+
#include "../usb_camera/CameraCapture.h"
99
#include "helpers/OStreamCapture.h"
1010

1111
using namespace std;
1212

1313
namespace etrobocon2025_test {
1414
// CameraCaptureクラスがインスタンス化ができるか確認するテスト
15-
TEST(CameraCapureTest, CameraCapureInit)
15+
TEST(CameraCaptureTest, CameraCaptureInit)
1616
{
1717
CameraCapture cap;
1818
int expected = 0;
@@ -21,7 +21,7 @@ namespace etrobocon2025_test {
2121
}
2222

2323
// 有効なcameraIDを指定した場合のテスト
24-
TEST(CameraCapureTest, SetCameraIDTrue)
24+
TEST(CameraCaptureTest, SetCameraIDTrue)
2525
{
2626
CameraCapture cap;
2727
int expected = 1;
@@ -32,7 +32,7 @@ namespace etrobocon2025_test {
3232
}
3333

3434
// 無効なcameraIDを指定した場合のテスト
35-
TEST(CameraCapureTest, SetCameraIDFalse)
35+
TEST(CameraCaptureTest, SetCameraIDFalse)
3636
{
3737
CameraCapture cap;
3838
int expected = 0;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author Haranaruki
55
*/
66

7-
#include "CameraCapure.h"
7+
#include "CameraCapture.h"
88

99
CameraCapture::CameraCapture() : cameraID(0) {}
1010

@@ -82,14 +82,14 @@ bool CameraCapture::getFrames(cv::Mat* frames, int numFrames, double seconds)
8282
return allSuccess;
8383
}
8484

85-
bool CameraCapture::saveLatestFrame(std::string filepath, std::string filename)
85+
bool CameraCapture::saveFrame(const cv::Mat& frame, std::string filepath, std::string filename)
8686
{
87-
if(latestFrame.empty()) {
87+
if(frame.empty()) {
8888
std::cerr << "保存するフレームがありません。" << std::endl;
8989
return false;
9090
}
9191
std::string fullpath = filepath + "/" + filename + ".JPEG";
92-
if(!cv::imwrite(fullpath, latestFrame)) {
92+
if(!cv::imwrite(fullpath, frame)) {
9393
std::cerr << "画像の保存に失敗しました: " << fullpath << std::endl;
9494
return false;
9595
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#ifndef CAMERACAPTURE_H
88
#define CAMERACAPTURE_H
99

10-
#include <iostream>
1110
#include <opencv2/opencv.hpp>
11+
#include <iostream>
1212
#include <vector>
1313
#include <string>
1414
#include <thread>
@@ -29,7 +29,7 @@ class CameraCapture {
2929
void setCapProps(double width, double height);
3030
bool getFrame(cv::Mat& outFrame);
3131
bool getFrames(cv::Mat* frames, int numFrames, double seconds);
32-
bool saveLatestFrame(std::string filepath, std::string filename);
32+
bool saveFrame(const cv::Mat& frame, std::string filepath, std::string filename);
3333
};
3434

3535
#endif

0 commit comments

Comments
 (0)