Skip to content

Commit

Permalink
Samples: Automatic updates to public repository
Browse files Browse the repository at this point in the history
Remember to do the following:
    1. Ensure that modified/deleted/new files are correct
    2. Make this commit message relevant for the changes
    3. Force push
    4. Delete branch after PR is merged

If this commit is an update from one SDK version to another,
make sure to create a release tag for previous version.
  • Loading branch information
csu-bot-zivid committed Dec 20, 2023
1 parent c79807f commit d140de3
Showing 1 changed file with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ namespace
}


std::string getProjectorImageFileForGivenCamera(const Zivid::Camera &camera)
{
const auto model = camera.info().model().value();
switch(model)
{
case Zivid::CameraInfo::Model::ValueType::zividTwo:
// intentional fallthrough
case Zivid::CameraInfo::Model::ValueType::zividTwoL100:
return std::string(ZIVID_SAMPLE_DATA_DIR) + "/ZividLogoZivid2ProjectorResolution.png";
case Zivid::CameraInfo::Model::ValueType::zivid2PlusM130:
// intentional fallthrough
case Zivid::CameraInfo::Model::ValueType::zivid2PlusM60:
// intentional fallthrough
case Zivid::CameraInfo::Model::ValueType::zivid2PlusL110:
return std::string(ZIVID_SAMPLE_DATA_DIR) + "/ZividLogoZivid2PlusProjectorResolution.png";
case Zivid::CameraInfo::Model::ValueType::zividOnePlusSmall:
// intentional fallthrough
case Zivid::CameraInfo::Model::ValueType::zividOnePlusMedium:
// intentional fallthrough
case Zivid::CameraInfo::Model::ValueType::zividOnePlusLarge:
throw std::invalid_argument("Projecting images is not supported for Zivid One+ cameras");
}
throw std::invalid_argument("Invalid camera model");
}

} // namespace

int main()
Expand All @@ -51,7 +76,7 @@ int main()
auto camera = zivid.connectCamera();

std::string imageFile = std::string(ZIVID_SAMPLE_DATA_DIR) + "/ZividLogo.png";
std::cout << "Reading 2D image from file: " << imageFile << std::endl;
std::cout << "Reading 2D image (of arbitrary resolution) from file: " << imageFile << std::endl;
const auto inputImage = cv::imread(imageFile, cv::IMREAD_UNCHANGED);

std::cout << "input image size: " << inputImage.size() << std::endl;
Expand Down Expand Up @@ -90,6 +115,22 @@ int main()

} // projectedImageHandle now goes out of scope, thereby stopping the projection

std::string projectorImageFileForGivenCamera = getProjectorImageFileForGivenCamera(camera);

std::cout << "Reading 2D image (of resolution matching the Zivid camera projector resolution) from file: "
<< projectorImageFileForGivenCamera << std::endl;
const auto projectorImageForGivenCamera = Zivid::Image<Zivid::ColorBGRA>(projectorImageFileForGivenCamera);

{ // A Local Scope to handle the projected image lifetime

auto projectedImageHandle =
Zivid::Experimental::Projection::showImage(camera, projectorImageForGivenCamera);

std::cout << "Press enter to stop projecting..." << std::endl;
std::cin.get();

} // projectedImageHandle now goes out of scope, thereby stopping the projection

std::cout << "Done" << std::endl;
}
catch(const std::exception &e)
Expand Down

0 comments on commit d140de3

Please sign in to comment.