camera: remove traces of old implementation
This commit is contained in:
parent
be585f91c2
commit
88cc5e2687
|
@ -89,9 +89,7 @@ struct Args {
|
|||
/// Run debug console
|
||||
#[arg(long)]
|
||||
debug: bool,
|
||||
// /// Use webcam as Pocket Camera emulation
|
||||
// #[arg(short, long)]
|
||||
// camera: bool,
|
||||
|
||||
/// Record frames to image sequence
|
||||
#[arg(long)]
|
||||
record: bool,
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
use gb_emu_lib::connect::PocketCamera;
|
||||
use nokhwa::{
|
||||
pixel_format,
|
||||
utils::{CameraIndex, RequestedFormat, RequestedFormatType},
|
||||
Camera,
|
||||
};
|
||||
use send_wrapper::SendWrapper;
|
||||
|
||||
pub struct Webcam {
|
||||
camera: SendWrapper<Camera>,
|
||||
scaled_buffer: [u8; 128 * 128],
|
||||
}
|
||||
|
||||
impl Webcam {
|
||||
pub fn new() -> Self {
|
||||
let format = RequestedFormat::new::<pixel_format::RgbFormat>(
|
||||
RequestedFormatType::AbsoluteHighestResolution,
|
||||
);
|
||||
|
||||
let mut camera = SendWrapper::new(
|
||||
Camera::new(CameraIndex::Index(0), format).expect("Couldn't open camera"),
|
||||
);
|
||||
camera
|
||||
.set_frame_format(nokhwa::utils::FrameFormat::YUYV)
|
||||
.expect("couldnt set frame format to yuyv");
|
||||
|
||||
if let Ok(formats) = camera.compatible_fourcc() {
|
||||
if formats.is_empty() {
|
||||
println!("no compatible frame formats listed");
|
||||
}
|
||||
for f in formats {
|
||||
println!("compatible frame format: {f:?}");
|
||||
}
|
||||
} else {
|
||||
println!("couldnt get frame formats")
|
||||
}
|
||||
|
||||
println!("current camera format: {:?}", camera.camera_format());
|
||||
|
||||
if let Ok(formats) = camera.compatible_camera_formats() {
|
||||
if formats.is_empty() {
|
||||
println!("camera formats is empty");
|
||||
}
|
||||
for f in formats {
|
||||
println!("supports camera format {f:?}");
|
||||
}
|
||||
} else {
|
||||
println!("couldnt get camera formats");
|
||||
}
|
||||
|
||||
Self {
|
||||
camera,
|
||||
scaled_buffer: [0; 128 * 128],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PocketCamera for Webcam {
|
||||
fn get_image(&mut self) -> [u8; 128 * 128] {
|
||||
self.scaled_buffer
|
||||
}
|
||||
|
||||
fn begin_capture(&mut self) {
|
||||
let _height = self.camera.resolution().height() as usize;
|
||||
let width = self.camera.resolution().width() as usize;
|
||||
// let frame = self.camera.frame_raw().expect("couldn't get frame");
|
||||
self.camera
|
||||
.set_frame_format(nokhwa::utils::FrameFormat::RAWRGB)
|
||||
.unwrap();
|
||||
let frame = self.camera.frame().expect("couldn't get frame");
|
||||
println!("source format: {:?}", frame.source_frame_format());
|
||||
|
||||
let decoded = frame
|
||||
.decode_image::<pixel_format::RgbFormat>()
|
||||
.expect("couldn't decode image");
|
||||
let pixels = decoded.pixels().collect::<Vec<_>>();
|
||||
|
||||
for y in 0..128 {
|
||||
for x in 0..128 {
|
||||
self.scaled_buffer[y * 128 + x] = pixels[((y * width) + x) * 2][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init(&mut self) {
|
||||
self.camera.open_stream().expect("couldn't open stream");
|
||||
self.camera
|
||||
.set_frame_format(nokhwa::utils::FrameFormat::YUYV)
|
||||
.unwrap();
|
||||
|
||||
println!(
|
||||
"opened stream! current format: {:?}",
|
||||
self.camera.camera_format()
|
||||
);
|
||||
// let format = RequestedFormat::new::<pixel_format::LumaFormat>(
|
||||
// RequestedFormatType::AbsoluteHighestResolution,
|
||||
// );
|
||||
// self.camera
|
||||
// .set_camera_requset(format)
|
||||
// .expect("couldn't set format again");
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
#![feature(let_chains, if_let_guard, iter_array_chunks)]
|
||||
|
||||
#[cfg(feature = "camera")]
|
||||
use camera::Webcam;
|
||||
|
||||
use gb_emu_lib::{
|
||||
config::{NamedConfig, CONFIG_MANAGER},
|
||||
connect::{
|
||||
|
@ -19,8 +16,6 @@ use std::{
|
|||
use window::{RendererChannel, WindowManager, WindowType};
|
||||
|
||||
pub mod audio;
|
||||
#[cfg(feature = "camera")]
|
||||
mod camera;
|
||||
pub mod debug;
|
||||
pub mod window;
|
||||
|
||||
|
|
Loading…
Reference in a new issue